mirror of
https://github.com/curl/curl.git
synced 2025-01-30 14:22:33 +08:00
http2: RST the stream if we stop it on our own will
For the "simulated 304" case the done-call isn't considered "premature" but since the server didn't close the stream it needs to be reset to stop delivering data. Closes #8664
This commit is contained in:
parent
3fa634a337
commit
fda4b81635
24
lib/http2.c
24
lib/http2.c
@ -825,10 +825,14 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
|
||||
|
||||
/* get the stream from the hash based on Stream ID */
|
||||
data_s = nghttp2_session_get_stream_user_data(session, stream_id);
|
||||
if(!data_s)
|
||||
/* Receiving a Stream ID not in the hash should not happen, this is an
|
||||
internal error more than anything else! */
|
||||
return NGHTTP2_ERR_CALLBACK_FAILURE;
|
||||
if(!data_s) {
|
||||
/* Receiving a Stream ID not in the hash should not happen - unless
|
||||
we have aborted a transfer artificially and there were more data
|
||||
in the pipeline. Silently ignore. */
|
||||
H2BUGF(fprintf(stderr, "Data for stream %u but it doesn't exist\n",
|
||||
stream_id));
|
||||
return 0;
|
||||
}
|
||||
|
||||
stream = data_s->req.p.http;
|
||||
if(!stream)
|
||||
@ -1234,17 +1238,19 @@ void Curl_http2_done(struct Curl_easy *data, bool premature)
|
||||
!httpc->h2) /* not HTTP/2 ? */
|
||||
return;
|
||||
|
||||
if(premature) {
|
||||
/* do this before the reset handling, as that might clear ->stream_id */
|
||||
if(http->stream_id == httpc->pause_stream_id) {
|
||||
H2BUGF(infof(data, "DONE the pause stream (%x)", http->stream_id));
|
||||
httpc->pause_stream_id = 0;
|
||||
}
|
||||
if(premature || (!http->closed && http->stream_id)) {
|
||||
/* RST_STREAM */
|
||||
set_transfer(httpc, data); /* set the transfer */
|
||||
H2BUGF(infof(data, "RST stream %x", http->stream_id));
|
||||
if(!nghttp2_submit_rst_stream(httpc->h2, NGHTTP2_FLAG_NONE,
|
||||
http->stream_id, NGHTTP2_STREAM_CLOSED))
|
||||
(void)nghttp2_session_send(httpc->h2);
|
||||
}
|
||||
if(http->stream_id == httpc->pause_stream_id) {
|
||||
H2BUGF(infof(data, "DONE the pause stream!"));
|
||||
httpc->pause_stream_id = 0;
|
||||
}
|
||||
|
||||
if(data->state.drain)
|
||||
drained_transfer(data, httpc);
|
||||
|
Loading…
Reference in New Issue
Block a user