MCPcopy
hub / github.com/valyala/fasthttp / TestRequestContentTypeDefaultNotEmpty

Function TestRequestContentTypeDefaultNotEmpty

header_test.go:1765–1791  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1763}
1764
1765func TestRequestContentTypeDefaultNotEmpty(t *testing.T) {
1766 t.Parallel()
1767
1768 var h RequestHeader
1769 h.SetMethod(MethodPost)
1770 h.SetHost("example.com")
1771 h.SetContentLength(5)
1772
1773 w := &bytes.Buffer{}
1774 bw := bufio.NewWriter(w)
1775 if err := h.Write(bw); err != nil {
1776 t.Fatalf("Unexpected error: %v", err)
1777 }
1778 if err := bw.Flush(); err != nil {
1779 t.Fatalf("Unexpected error: %v", err)
1780 }
1781
1782 var h1 RequestHeader
1783 br := bufio.NewReader(w)
1784 if err := h1.Read(br); err != nil {
1785 t.Fatalf("Unexpected error: %v", err)
1786 }
1787
1788 if string(h1.contentType) != "application/octet-stream" {
1789 t.Fatalf("unexpected Content-Type %q. Expecting %q", h1.contentType, "application/octet-stream")
1790 }
1791}
1792
1793func TestRequestContentTypeNoDefault(t *testing.T) {
1794 t.Parallel()

Callers

nothing calls this directly

Calls 7

SetMethodMethod · 0.95
SetHostMethod · 0.95
SetContentLengthMethod · 0.95
WriteMethod · 0.95
FlushMethod · 0.95
ReadMethod · 0.95
NewReaderMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…