aboutsummaryrefslogtreecommitdiff
path: root/fs.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 /fs.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 'fs.go')
-rw-r--r--fs.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs.go b/fs.go
index 90bbf12..4bbb3fd 100644
--- a/fs.go
+++ b/fs.go
@@ -898,16 +898,16 @@ func (h *fsHandler) handleRequest(ctx *RequestCtx) {
hdr := &ctx.Response.Header
if ff.compressed {
if fileEncoding == "br" {
- hdr.SetCanonical(strContentEncoding, strBr)
+ hdr.SetContentEncodingBytes(strBr)
} else if fileEncoding == "gzip" {
- hdr.SetCanonical(strContentEncoding, strGzip)
+ hdr.SetContentEncodingBytes(strGzip)
}
}
statusCode := StatusOK
contentLength := ff.contentLength
if h.acceptByteRange {
- hdr.SetCanonical(strAcceptRanges, strBytes)
+ hdr.setNonSpecial(strAcceptRanges, strBytes)
if len(byteRange) > 0 {
startPos, endPos, err := ParseByteRange(byteRange, contentLength)
if err != nil {
@@ -930,7 +930,7 @@ func (h *fsHandler) handleRequest(ctx *RequestCtx) {
}
}
- hdr.SetCanonical(strLastModified, ff.lastModifiedStr)
+ hdr.setNonSpecial(strLastModified, ff.lastModifiedStr)
if !ctx.IsHead() {
ctx.SetBodyStream(r, contentLength)
} else {