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

Function TestResponseHeaderEmptyValueFromHeader

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

Source from the content-addressed store, hash-verified

306}
307
308func TestResponseHeaderEmptyValueFromHeader(t *testing.T) {
309 t.Parallel()
310
311 var h1 ResponseHeader
312 h1.SetContentType("foo/bar")
313 h1.Set("EmptyValue1", "")
314 h1.Set("EmptyValue2", " ")
315 s := h1.String()
316
317 var h ResponseHeader
318 br := bufio.NewReader(bytes.NewBufferString(s))
319 if err := h.Read(br); err != nil {
320 t.Fatalf("unexpected error: %v", err)
321 }
322 if !bytes.Equal(h.ContentType(), h1.ContentType()) {
323 t.Fatalf("unexpected content-type: %q. Expecting %q", h.ContentType(), h1.ContentType())
324 }
325 v1 := h.Peek("EmptyValue1")
326 if len(v1) > 0 {
327 t.Fatalf("expecting empty value. Got %q", v1)
328 }
329 v2 := h.Peek("EmptyValue2")
330 if len(v2) > 0 {
331 t.Fatalf("expecting empty value. Got %q", v2)
332 }
333}
334
335func TestResponseHeaderEmptyValueFromString(t *testing.T) {
336 t.Parallel()

Callers

nothing calls this directly

Calls 7

SetMethod · 0.95
StringMethod · 0.95
ReadMethod · 0.95
ContentTypeMethod · 0.95
PeekMethod · 0.95
NewReaderMethod · 0.80
SetContentTypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…