diff options
author | Sebastian Schepens <sebastian.schepens@mercadolibre.com> | 2016-02-22 14:36:58 -0300 |
---|---|---|
committer | Sebastian Schepens <sebastian.schepens@mercadolibre.com> | 2016-02-22 14:36:58 -0300 |
commit | 889c65bae695e88561a97b52fb9e029daac02c55 (patch) | |
tree | db43ae47d67de42d5d5f9044b1dd2227fab7ccd9 /compress.go | |
parent | client: use exponential backoff algorithm for sleeping between unsuccessful a... (diff) | |
download | fasthttp-889c65bae695e88561a97b52fb9e029daac02c55.tar.gz fasthttp-889c65bae695e88561a97b52fb9e029daac02c55.tar.bz2 fasthttp-889c65bae695e88561a97b52fb9e029daac02c55.zip |
Added BodyInflate and WriteInflate to match BodyGunzip and WriteGunzip
Diffstat (limited to 'compress.go')
-rw-r--r-- | compress.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/compress.go b/compress.go index 5b9e58d..c3b81cf 100644 --- a/compress.go +++ b/compress.go @@ -171,6 +171,23 @@ func WriteGunzip(w io.Writer, p []byte) (int, error) { return nn, err } +// WriteInflate writes inflated p to w and returns the number of uncompressed +// bytes written to w. +func WriteInflate(w io.Writer, p []byte) (int, error) { + r := &byteSliceReader{p} + zr, err := acquireFlateReader(r) + if err != nil { + return 0, err + } + n, err := copyZeroAlloc(w, zr) + releaseFlateReader(zr) + nn := int(n) + if int64(nn) != n { + return 0, fmt.Errorf("too much data inflated: %d", n) + } + return nn, err +} + // AppendGunzipBytes append gunzipped src to dst and returns the resulting dst. func AppendGunzipBytes(dst, src []byte) ([]byte, error) { w := &byteSliceWriter{dst} |