Merge pull request #273 from iamqizhao/master

handle empty data frame
This commit is contained in:
Qi Zhao
2015-07-30 13:04:36 -07:00
2 changed files with 37 additions and 34 deletions

View File

@ -529,6 +529,7 @@ func (t *http2Client) handleData(f *http2.DataFrame) {
return
}
size := len(f.Data())
if size > 0 {
if err := s.fc.onData(uint32(size)); err != nil {
if _, ok := err.(ConnectionError); ok {
t.notifyError(err)
@ -553,7 +554,7 @@ 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) {

View File

@ -322,6 +322,7 @@ func (t *http2Server) handleData(f *http2.DataFrame) {
return
}
size := len(f.Data())
if size > 0 {
if err := s.fc.onData(uint32(size)); err != nil {
if _, ok := err.(ConnectionError); ok {
grpclog.Printf("transport: http2Server %v", err)
@ -338,6 +339,7 @@ func (t *http2Server) handleData(f *http2.DataFrame) {
data := make([]byte, size)
copy(data, f.Data())
s.write(recvMsg{data: data})
}
if f.Header().Flags.Has(http2.FlagDataEndStream) {
// Received the end of stream from the client.
s.mu.Lock()