author | Mikio Hara
<mikioh.mikioh@gmail.com> 2016-06-07 20:04:34 UTC |
committer | Andrew Gerrand
<adg@golang.org> 2016-06-08 02:50:06 UTC |
parent | 154d9f9ea81208afed560f4cf27b4860c8ed1904 |
http2/pipe.go | +6 | -0 |
http2/transport.go | +1 | -1 |
diff --git a/http2/pipe.go b/http2/pipe.go index 69446e7..53b7a1d 100644 --- a/http2/pipe.go +++ b/http2/pipe.go @@ -29,6 +29,12 @@ type pipeBuffer interface { io.Reader } +func (p *pipe) Len() int { + p.mu.Lock() + defer p.mu.Unlock() + return p.b.Len() +} + // Read waits until data is available and copies bytes // from the buffer into p. func (p *pipe) Read(d []byte) (n int, err error) { diff --git a/http2/transport.go b/http2/transport.go index 2a4abfa..060471e 100644 --- a/http2/transport.go +++ b/http2/transport.go @@ -1462,7 +1462,7 @@ func (b transportResponseBody) Read(p []byte) (n int, err error) { // Consider any buffered body data (read from the conn but not // consumed by the client) when computing flow control for this // stream. - v := int(cs.inflow.available()) + cs.bufPipe.b.Len() + v := int(cs.inflow.available()) + cs.bufPipe.Len() if v < transportDefaultStreamFlow-transportDefaultStreamMinRefresh { streamAdd = int32(transportDefaultStreamFlow - v) cs.inflow.add(streamAdd)