fix: allow ResponseReader.Reader to be wrapped by transcoders

fixes -minify errors
This commit is contained in:
Barna Csorogi 2017-01-14 03:44:07 +01:00
parent 1d5b6eff72
commit 480053a71a
2 changed files with 8 additions and 5 deletions

View file

@ -69,7 +69,7 @@ func (p *Proxy) handle(w http.ResponseWriter, r *http.Request) error {
rw := newResponseWriter(w)
rr := newResponseReader(resp)
err = p.proxyResponse(rw, rr)
read := rr.Count()
read := rr.counter.Count()
written := rw.rw.Count()
log.Printf("transcoded: %d -> %d (%3.1f%%)", read, written, float64(written)/float64(read)*100)
atomic.AddUint64(&p.ReadCount, read)

View file

@ -9,14 +9,17 @@ import (
)
type ResponseReader struct {
datacounter.ReaderCounter
r *http.Response
io.Reader
counter *datacounter.ReaderCounter
r *http.Response
}
func newResponseReader(r *http.Response) *ResponseReader {
counter := datacounter.NewReaderCounter(r.Body)
return &ResponseReader{
ReaderCounter: *datacounter.NewReaderCounter(r.Body),
r: r,
Reader: counter,
counter: counter,
r: r,
}
}