diff options
author | Erik Dubbelboer <erik@dubbelboer.com> | 2020-05-15 15:36:26 +0200 |
---|---|---|
committer | Erik Dubbelboer <erik@dubbelboer.com> | 2020-05-15 15:36:26 +0200 |
commit | 339ad36634b68ab5b4d90fb9991e38d5020a1039 (patch) | |
tree | 167e613ce9b8eef1d3b92c18b00d4039cbc8df91 /strings.go | |
parent | Don't wrap conn with a TLS Client if it's already a TLS Conn (diff) | |
download | fasthttp-339ad36634b68ab5b4d90fb9991e38d5020a1039.tar.gz fasthttp-339ad36634b68ab5b4d90fb9991e38d5020a1039.tar.bz2 fasthttp-339ad36634b68ab5b4d90fb9991e38d5020a1039.zip |
Add Brotli support
New Functions:
CompressHandlerBrotliLevel(h RequestHandler, brotliLevel, otherLevel int) RequestHandler
Request.BodyUnbrotli() ([]byte, error)
Response.BodyUnbrotli() ([]byte, error)
AppendBrotliBytesLevel(dst, src []byte, level int) []byte
WriteBrotliLevel(w io.Writer, p []byte, level int) (int, error)
WriteBrotli(w io.Writer, p []byte) (int, error)
AppendBrotliBytes(dst, src []byte) []byte
WriteUnbrotli(w io.Writer, p []byte) (int, error)
AppendUnbrotliBytes(dst, src []byte) ([]byte, error)
New Constants:
CompressBrotliNoCompression
CompressBrotliBestSpeed
CompressBrotliBestCompression
CompressBrotliDefaultCompression
Brotli compression levels are different from gzip/flate. Because of this we have separate level constants and CompressHandlerBrotliLevel takes 2 levels.
I didn't add Brotli support to CompressHandler as this could cause a spike in CPU usage when users upgrade fasthttp.
fasthttp.CompressBrotliDefaultCompression is not the same as
brotli.DefaultCompression. brotli.DefaultCompression is more than twice
as slow as fasthttp.CompressBrotliDefaultCompression which I thought was
unreasonable as default.
Diffstat (limited to 'strings.go')
-rw-r--r-- | strings.go | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -69,6 +69,7 @@ var ( strClose = []byte("close") strGzip = []byte("gzip") + strBr = []byte("br") strDeflate = []byte("deflate") strKeepAlive = []byte("keep-alive") strUpgrade = []byte("Upgrade") |