mirror of
https://git.phreedom.club/localhost_frssoft/compy.git
synced 2024-11-27 02:21:34 +00:00
Consume gzip stream in test
Also close writer since this test previously failed due to truncated output.
This commit is contained in:
parent
f8cb20ade6
commit
ecfa095a14
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
gzipp "compress/gzip"
|
||||
jpegp "image/jpeg"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
|
@ -83,7 +84,10 @@ func (s *CompyTest) TestGzip(c *C) {
|
|||
c.Assert(resp.StatusCode, Equals, 200)
|
||||
c.Assert(resp.Header.Get("Content-Encoding"), Equals, "gzip")
|
||||
|
||||
_, err = gzipp.NewReader(resp.Body)
|
||||
gzr, err := gzipp.NewReader(resp.Body)
|
||||
c.Assert(err, IsNil)
|
||||
defer gzr.Close()
|
||||
_, err = ioutil.ReadAll(gzr)
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ func (t *Gzip) Transcode(w *proxy.ResponseWriter, r *proxy.ResponseReader, heade
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer gzw.Flush()
|
||||
defer gzw.Close()
|
||||
w.Writer = gzw
|
||||
w.Header().Set("Content-Encoding", "gzip")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue