diff --git a/transport/http2_client.go b/transport/http2_client.go index 8f79ad96..f2755749 100644 --- a/transport/http2_client.go +++ b/transport/http2_client.go @@ -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) {