fasthttp
fasthttp copied to clipboard
[Bug/Question] SetCanonical does not let you Peek the value
I can't seem to Peek the header value after using SetCanonical with a second capital letter like ETag or WWW-, I'm wondering if this is intended behaviour without using ctx.Response.Header.DisableNormalizing().
func main() {
ctx := &fasthttp.RequestCtx{}
//ctx.Response.Header.Set("ETag", "13-1831710635")
ctx.Response.Header.SetCanonical([]byte("ETag"), []byte("13-1831710635"))
fmt.Println(string(ctx.Response.Header.Header()))
// HTTP/1.1 200 OK
// Date: Fri, 04 Sep 2020 19:24:43 GMT
// ETag: 13-1831710635
fmt.Println(string(ctx.Response.Header.Peek("ETag")))
// ""
}
This is indeed intended behavior, Header.Peek will normalize the header to Etag and won't be able to find it. There currently isn't a Header.PeekCanonical(), I'm also not sure if we should add it.
Since ETag is mostly canonicalized like ETag instead of Etag like fasthttp does I'm wondering if we should make an exception for that.