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

Function TestResponseHeaderEmptyValueFromString

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

Source from the content-addressed store, hash-verified

333}
334
335func TestResponseHeaderEmptyValueFromString(t *testing.T) {
336 t.Parallel()
337
338 s := "HTTP/1.1 200 OK\r\n" +
339 "EmptyValue1:\r\n" +
340 "Content-Type: foo/bar\r\n" +
341 "EmptyValue2: \r\n" +
342 "\r\n"
343
344 var h ResponseHeader
345 br := bufio.NewReader(bytes.NewBufferString(s))
346 if err := h.Read(br); err != nil {
347 t.Fatalf("unexpected error: %v", err)
348 }
349 if string(h.ContentType()) != "foo/bar" {
350 t.Fatalf("unexpected content-type: %q. Expecting %q", h.ContentType(), "foo/bar")
351 }
352 v1 := h.Peek("EmptyValue1")
353 if len(v1) > 0 {
354 t.Fatalf("expecting empty value. Got %q", v1)
355 }
356 v2 := h.Peek("EmptyValue2")
357 if len(v2) > 0 {
358 t.Fatalf("expecting empty value. Got %q", v2)
359 }
360}
361
362func TestRequestHeaderEmptyValueFromHeader(t *testing.T) {
363 t.Parallel()

Callers

nothing calls this directly

Calls 4

ReadMethod · 0.95
ContentTypeMethod · 0.95
PeekMethod · 0.95
NewReaderMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…