diff options
author | Sergey Ponomarev <stokito@gmail.com> | 2022-06-06 09:59:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-06 08:59:16 +0200 |
commit | 35aca7b6dfd24a5aa47750137bc4ece280e9ce91 (patch) | |
tree | 29d24f166f2719729c00f4ad17e10146191e6558 /header.go | |
parent | header.go Referer() optimize (#1313) (diff) | |
download | fasthttp-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.go | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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. |