Skip to content

Commit 9b72053

Browse files
committed
1 parent 48e90ed commit 9b72053

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/node_http2.cc

+13-1
Original file line numberDiff line numberDiff line change
@@ -2184,6 +2184,17 @@ ssize_t Http2Stream::Provider::Stream::OnRead(nghttp2_session* handle,
21842184

21852185
size_t amount = 0; // amount of data being sent in this data frame.
21862186

2187+
// Remove all empty chunks from the head of the queue.
2188+
// This is done here so that .write('', cb) is still a meaningful way to
2189+
// find out when the HTTP2 stream wants to consume data, and because the
2190+
// StreamBase API allows empty input chunks.
2191+
while (!stream->queue_.empty() && stream->queue_.front().buf.len == 0) {
2192+
WriteWrap* finished = stream->queue_.front().req_wrap;
2193+
stream->queue_.pop();
2194+
if (finished != nullptr)
2195+
finished->Done(0);
2196+
}
2197+
21872198
if (!stream->queue_.empty()) {
21882199
DEBUG_HTTP2SESSION2(session, "stream %d has pending outbound data", id);
21892200
amount = std::min(stream->available_outbound_length_, length);
@@ -2197,7 +2208,8 @@ ssize_t Http2Stream::Provider::Stream::OnRead(nghttp2_session* handle,
21972208
}
21982209
}
21992210

2200-
if (amount == 0 && stream->IsWritable() && stream->queue_.empty()) {
2211+
if (amount == 0 && stream->IsWritable()) {
2212+
CHECK(stream->queue_.empty());
22012213
DEBUG_HTTP2SESSION2(session, "deferring stream %d", id);
22022214
return NGHTTP2_ERR_DEFERRED;
22032215
}

0 commit comments

Comments
 (0)