aboutsummaryrefslogtreecommitdiff
path: root/header.go
diff options
context:
space:
mode:
authorGravatar Sergey Ponomarev <stokito@gmail.com> 2022-06-06 09:59:16 +0300
committerGravatar GitHub <noreply@github.com> 2022-06-06 08:59:16 +0200
commit35aca7b6dfd24a5aa47750137bc4ece280e9ce91 (patch)
tree29d24f166f2719729c00f4ad17e10146191e6558 /header.go
parentheader.go Referer() optimize (#1313) (diff)
downloadfasthttp-35aca7b6dfd24a5aa47750137bc4ece280e9ce91.tar.gz
fasthttp-35aca7b6dfd24a5aa47750137bc4ece280e9ce91.tar.bz2
fasthttp-35aca7b6dfd24a5aa47750137bc4ece280e9ce91.zip
BodyDecoded() for request and responses (#1308)
* header.go ContentEncoding() getter and setters For Response the CE header is stored into a separate field because compressed responses are often used. But for the Request let's just peek and store it from headers map * http.go: New BodyUncompressed() method for request and responses The new method returns a body and uncompress if it's gzipped
Diffstat (limited to 'header.go')
-rw-r--r--header.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/header.go b/header.go
index e7616df..e960177 100644
--- a/header.go
+++ b/header.go
@@ -371,6 +371,21 @@ func (h *RequestHeader) SetContentTypeBytes(contentType []byte) {
h.contentType = append(h.contentType[:0], contentType...)
}
+// ContentEncoding returns Content-Encoding header value.
+func (h *RequestHeader) ContentEncoding() []byte {
+ return peekArgBytes(h.h, strContentEncoding)
+}
+
+// SetContentEncoding sets Content-Encoding header value.
+func (h *RequestHeader) SetContentEncoding(contentEncoding string) {
+ h.SetBytesK(strContentEncoding, contentEncoding)
+}
+
+// SetContentEncodingBytes sets Content-Encoding header value.
+func (h *RequestHeader) SetContentEncodingBytes(contentEncoding []byte) {
+ h.setNonSpecial(strContentEncoding, contentEncoding)
+}
+
// SetMultipartFormBoundary sets the following Content-Type:
// 'multipart/form-data; boundary=...'
// where ... is substituted by the given boundary.