http2Client: send reset stream when closing the stream on protocol error (#2030)

This commit is contained in:
lyuxuan
2018-04-30 11:16:00 -07:00
committed by GitHub
parent 8b85126464
commit 71fe8dfd61

View File

@ -1022,8 +1022,7 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
atomic.StoreUint32(&s.bytesReceived, 1)
var state decodeState
if err := state.decodeResponseHeader(frame); err != nil {
// TODO(mmukhi, dfawley): Perhaps send a reset stream.
t.closeStream(s, err, false, http2.ErrCodeNo, nil, nil, false)
t.closeStream(s, err, true, http2.ErrCodeProtocol, nil, nil, false)
// Something wrong. Stops reading even when there is remaining.
return
}
@ -1105,8 +1104,7 @@ func (t *http2Client) reader() {
t.mu.Unlock()
if s != nil {
// use error detail to provide better err message
// TODO(mmukhi, dfawley): Perhaps send a RST_STREAM to the server.
t.closeStream(s, streamErrorf(http2ErrConvTab[se.Code], "%v", t.framer.fr.ErrorDetail()), false, http2.ErrCodeNo, nil, nil, false)
t.closeStream(s, streamErrorf(http2ErrConvTab[se.Code], "%v", t.framer.fr.ErrorDetail()), true, http2.ErrCodeProtocol, nil, nil, false)
}
continue
} else {