Merge pull request #253 from awpr-google/honor_data_end_stream

Honor END_STREAM flags in HTTP/2 Data frames.
This commit is contained in:
Qi Zhao
2015-07-24 16:40:22 -07:00

View File

@ -550,6 +550,21 @@ func (t *http2Client) handleData(f *http2.DataFrame) {
data := make([]byte, size)
copy(data, f.Data())
s.write(recvMsg{data: data})
// The server has closed the stream without sending trailers. Record that
// the read direction is closed, and set the status appropriately.
if f.FrameHeader.Flags.Has(http2.FlagDataEndStream) {
s.mu.Lock()
if (s.state == streamWriteDone) {
s.state = streamDone
} else {
s.state = streamReadDone
}
s.statusCode = codes.Internal
s.statusDesc = "server closed the stream without sending trailers"
s.mu.Unlock()
s.write(recvMsg{err: io.EOF})
}
}
func (t *http2Client) handleRSTStream(f *http2.RSTStreamFrame) {