Skip to content

Commit

Permalink
http2: use and support non-empty DATA frame with END_STREAM flag
Browse files Browse the repository at this point in the history
Adds support for reading from a stream where the final frame is a non-empty
DATA frame with the END_STREAM flag set, instead of hanging waiting for another
frame. When writing to a stream, uses a END_STREAM flag on final DATA frame
instead of adding an empty DATA frame.

BREAKING: http2 client now expects servers to properly support END_STREAM flag

Fixes: nodejs#31309
Fixes: nodejs#33891
Refs: https://nghttp2.org/documentation/types.html#c.nghttp2_on_data_chunk_recv_callback
  • Loading branch information
clshortfuse committed Jun 18, 2020
1 parent 0ef6956 commit ca21bd1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,12 @@ int Http2Session::OnDataChunkReceived(nghttp2_session* handle,
session->SendPendingData();
}
} while (len != 0);

// If end-stream flag is set, there is nothing more to read
if (flags & NGHTTP2_FLAG_END_STREAM) {
stream->EmitRead(UV_EOF);
return 0;
}

// If we are currently waiting for a write operation to finish, we should
// tell nghttp2 that we want to wait before we process more input data.
Expand Down

0 comments on commit ca21bd1

Please sign in to comment.