mirror of
https://git.phreedom.club/localhost_frssoft/compy.git
synced 2024-11-23 16:41:30 +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"
|
gzipp "compress/gzip"
|
||||||
jpegp "image/jpeg"
|
jpegp "image/jpeg"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -83,7 +84,10 @@ func (s *CompyTest) TestGzip(c *C) {
|
||||||
c.Assert(resp.StatusCode, Equals, 200)
|
c.Assert(resp.StatusCode, Equals, 200)
|
||||||
c.Assert(resp.Header.Get("Content-Encoding"), Equals, "gzip")
|
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)
|
c.Assert(err, IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ func (t *Gzip) Transcode(w *proxy.ResponseWriter, r *proxy.ResponseReader, heade
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer gzw.Flush()
|
defer gzw.Close()
|
||||||
w.Writer = gzw
|
w.Writer = gzw
|
||||||
w.Header().Set("Content-Encoding", "gzip")
|
w.Header().Set("Content-Encoding", "gzip")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue