aboutsummaryrefslogtreecommitdiff
path: root/server_test.go
diff options
context:
space:
mode:
authorGravatar Sergey Ponomarev <stokito@gmail.com> 2022-06-05 16:47:59 +0300
committerGravatar GitHub <noreply@github.com> 2022-06-05 15:47:59 +0200
commitc9f43eaa1b02d6867e489a39e92926c68facb60c (patch)
tree2f5343a5572a07eb207d2e7caf7b2480aad18c37 /server_test.go
parentOptimize server connection close logic (#1310) (diff)
downloadfasthttp-c9f43eaa1b02d6867e489a39e92926c68facb60c.tar.gz
fasthttp-c9f43eaa1b02d6867e489a39e92926c68facb60c.tar.bz2
fasthttp-c9f43eaa1b02d6867e489a39e92926c68facb60c.zip
Response.ContentEncoding(): store as field and avoid using Header.SetCanonical() (#1311)
* Response.ContentEncoding(): store as field The CE is not so often used for plain APIs responses and even not so often used for static files and on the fly compression. But still it should be checked each time. Also having a dedicated field getter and setter simplifies code * header.go Use shorter Response.setNonSpecial() and Request.setNonSpecial() methods instead of SetCanonical() The change should improve performance because the setSpecialHeader() call is omitted. As a downside on adding a new basic header field all putHeader() must be replaced with a direct getter and setter.
Diffstat (limited to 'server_test.go')
-rw-r--r--server_test.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/server_test.go b/server_test.go
index 65bcce3..6775ce6 100644
--- a/server_test.go
+++ b/server_test.go
@@ -1943,7 +1943,7 @@ func TestCompressHandler(t *testing.T) {
if err := resp.Read(br); err != nil {
t.Fatalf("unexpected error: %v", err)
}
- ce := resp.Header.Peek(HeaderContentEncoding)
+ ce := resp.Header.ContentEncoding()
if string(ce) != "" {
t.Fatalf("unexpected Content-Encoding: %q. Expecting %q", ce, "")
}
@@ -1963,7 +1963,7 @@ func TestCompressHandler(t *testing.T) {
if err := resp.Read(br); err != nil {
t.Fatalf("unexpected error: %v", err)
}
- ce = resp.Header.Peek(HeaderContentEncoding)
+ ce = resp.Header.ContentEncoding()
if string(ce) != "gzip" {
t.Fatalf("unexpected Content-Encoding: %q. Expecting %q", ce, "gzip")
}
@@ -1986,7 +1986,7 @@ func TestCompressHandler(t *testing.T) {
if err := resp.Read(br); err != nil {
t.Fatalf("unexpected error: %v", err)
}
- ce = resp.Header.Peek(HeaderContentEncoding)
+ ce = resp.Header.ContentEncoding()
if string(ce) != "gzip" {
t.Fatalf("unexpected Content-Encoding: %q. Expecting %q", ce, "gzip")
}
@@ -2009,7 +2009,7 @@ func TestCompressHandler(t *testing.T) {
if err := resp.Read(br); err != nil {
t.Fatalf("unexpected error: %v", err)
}
- ce = resp.Header.Peek(HeaderContentEncoding)
+ ce = resp.Header.ContentEncoding()
if string(ce) != "deflate" {
t.Fatalf("unexpected Content-Encoding: %q. Expecting %q", ce, "deflate")
}
@@ -2985,7 +2985,7 @@ func TestServerMaxRequestsPerConn(t *testing.T) {
if !resp.ConnectionClose() {
t.Fatal("Response must have 'connection: close' header")
}
- verifyResponseHeader(t, &resp.Header, 200, 0, string(defaultContentType))
+ verifyResponseHeader(t, &resp.Header, 200, 0, string(defaultContentType), "")
data, err := ioutil.ReadAll(br)
if err != nil {
@@ -4017,7 +4017,7 @@ func verifyResponse(t *testing.T, r *bufio.Reader, expectedStatusCode int, expec
if !bytes.Equal(resp.Body(), []byte(expectedBody)) {
t.Fatalf("Unexpected body %q. Expected %q", resp.Body(), []byte(expectedBody))
}
- verifyResponseHeader(t, &resp.Header, expectedStatusCode, len(resp.Body()), expectedContentType)
+ verifyResponseHeader(t, &resp.Header, expectedStatusCode, len(resp.Body()), expectedContentType, "")
return &resp
}