mirror of
https://git.phreedom.club/localhost_frssoft/compy.git
synced 2024-11-30 12:01:29 +00:00
fix: allow ResponseReader.Reader to be wrapped by transcoders
fixes -minify errors
This commit is contained in:
parent
1d5b6eff72
commit
480053a71a
|
@ -69,7 +69,7 @@ func (p *Proxy) handle(w http.ResponseWriter, r *http.Request) error {
|
||||||
rw := newResponseWriter(w)
|
rw := newResponseWriter(w)
|
||||||
rr := newResponseReader(resp)
|
rr := newResponseReader(resp)
|
||||||
err = p.proxyResponse(rw, rr)
|
err = p.proxyResponse(rw, rr)
|
||||||
read := rr.Count()
|
read := rr.counter.Count()
|
||||||
written := rw.rw.Count()
|
written := rw.rw.Count()
|
||||||
log.Printf("transcoded: %d -> %d (%3.1f%%)", read, written, float64(written)/float64(read)*100)
|
log.Printf("transcoded: %d -> %d (%3.1f%%)", read, written, float64(written)/float64(read)*100)
|
||||||
atomic.AddUint64(&p.ReadCount, read)
|
atomic.AddUint64(&p.ReadCount, read)
|
||||||
|
|
|
@ -9,14 +9,17 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type ResponseReader struct {
|
type ResponseReader struct {
|
||||||
datacounter.ReaderCounter
|
io.Reader
|
||||||
r *http.Response
|
counter *datacounter.ReaderCounter
|
||||||
|
r *http.Response
|
||||||
}
|
}
|
||||||
|
|
||||||
func newResponseReader(r *http.Response) *ResponseReader {
|
func newResponseReader(r *http.Response) *ResponseReader {
|
||||||
|
counter := datacounter.NewReaderCounter(r.Body)
|
||||||
return &ResponseReader{
|
return &ResponseReader{
|
||||||
ReaderCounter: *datacounter.NewReaderCounter(r.Body),
|
Reader: counter,
|
||||||
r: r,
|
counter: counter,
|
||||||
|
r: r,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue