mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
31 lines
692 B
Go
31 lines
692 B
Go
package fasthttp
|
|
|
|
import (
|
|
"bufio"
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestRequestHeaderSetContentType_Issue6(t *testing.T) {
|
|
contentType := "application/json"
|
|
|
|
var h RequestHeader
|
|
h.SetRequestURI("http://localhost/test")
|
|
h.SetContentType(contentType)
|
|
|
|
if string(h.ContentType()) != contentType {
|
|
t.Fatalf("unexpected content-type: %q. Expecting %q", h.ContentType(), contentType)
|
|
}
|
|
s := h.String()
|
|
|
|
var h1 RequestHeader
|
|
|
|
br := bufio.NewReader(bytes.NewBufferString(s))
|
|
if err := h1.Read(br); err != nil {
|
|
t.Fatalf("unexpected error: %s", err)
|
|
}
|
|
if string(h1.ContentType()) != contentType {
|
|
t.Fatalf("unexpected content-type: %q. Expecting %q", h1.ContentType(), contentType)
|
|
}
|
|
}
|