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

Function TestRequestHeaderConnectionClose

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

Source from the content-addressed store, hash-verified

1860}
1861
1862func TestRequestHeaderConnectionClose(t *testing.T) {
1863 t.Parallel()
1864
1865 var h RequestHeader
1866
1867 h.Set(HeaderConnection, "close")
1868 h.Set(HeaderHost, "foobar")
1869 if !h.ConnectionClose() {
1870 t.Fatalf("connection: close not set")
1871 }
1872
1873 var w bytes.Buffer
1874 bw := bufio.NewWriter(&w)
1875 if err := h.Write(bw); err != nil {
1876 t.Fatalf("unexpected error: %v", err)
1877 }
1878 if err := bw.Flush(); err != nil {
1879 t.Fatalf("unexpected error: %v", err)
1880 }
1881
1882 var h1 RequestHeader
1883 br := bufio.NewReader(&w)
1884 if err := h1.Read(br); err != nil {
1885 t.Fatalf("error when reading request header: %v", err)
1886 }
1887
1888 if !h1.ConnectionClose() {
1889 t.Fatalf("unexpected connection: close value: %v", h1.ConnectionClose())
1890 }
1891 if string(h1.Peek(HeaderConnection)) != "close" {
1892 t.Fatalf("unexpected connection value: %q. Expecting %q", h.Peek("Connection"), "close")
1893 }
1894}
1895
1896func TestRequestHeaderSetCookie(t *testing.T) {
1897 t.Parallel()

Callers

nothing calls this directly

Calls 7

SetMethod · 0.95
WriteMethod · 0.95
FlushMethod · 0.95
ReadMethod · 0.95
PeekMethod · 0.95
NewReaderMethod · 0.80
ConnectionCloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…