mirror of
https://github.com/curl/curl.git
synced 2026-07-27 17:48:55 +03:00
http2: auto reset stream on server eos
When a server signals EOS from its side and the curl upload is unfinished and the server has not given a positive HTTP status response, auto RST the stream to signal that the upload is incomplete and that the whole transfer can be stopped. Fixes the case where the server responds with 413 on an upload but does not RST the stream from its side, as httpd and others do. Reported-by: jkamp-aws on github Fixes #15316 Closes #15325
This commit is contained in:
parent
2ae8d9b579
commit
fe2a72029e
3 changed files with 47 additions and 5 deletions
23
lib/http2.c
23
lib/http2.c
|
|
@ -1119,9 +1119,6 @@ static CURLcode on_stream_frame(struct Curl_cfilter *cf,
|
|||
return CURLE_RECV_ERROR;
|
||||
}
|
||||
}
|
||||
if(frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
|
||||
drain_stream(cf, data, stream);
|
||||
}
|
||||
break;
|
||||
case NGHTTP2_HEADERS:
|
||||
if(stream->bodystarted) {
|
||||
|
|
@ -1137,10 +1134,10 @@ static CURLcode on_stream_frame(struct Curl_cfilter *cf,
|
|||
return CURLE_RECV_ERROR;
|
||||
|
||||
/* Only final status code signals the end of header */
|
||||
if(stream->status_code / 100 != 1) {
|
||||
if(stream->status_code / 100 != 1)
|
||||
stream->bodystarted = TRUE;
|
||||
else
|
||||
stream->status_code = -1;
|
||||
}
|
||||
|
||||
h2_xfer_write_resp_hd(cf, data, stream, STRCONST("\r\n"), stream->closed);
|
||||
|
||||
|
|
@ -1187,6 +1184,22 @@ static CURLcode on_stream_frame(struct Curl_cfilter *cf,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
|
||||
if(!stream->closed && !stream->body_eos &&
|
||||
((stream->status_code >= 400) || (stream->status_code < 200))) {
|
||||
/* The server did not give us a positive response and we are not
|
||||
* done uploading the request body. We need to stop doing that and
|
||||
* also inform the server that we aborted our side. */
|
||||
CURL_TRC_CF(data, cf, "[%d] EOS frame with unfinished upload and "
|
||||
"HTTP status %d, abort upload by RST",
|
||||
stream_id, stream->status_code);
|
||||
nghttp2_submit_rst_stream(ctx->h2, NGHTTP2_FLAG_NONE,
|
||||
stream->id, NGHTTP2_STREAM_CLOSED);
|
||||
stream->closed = TRUE;
|
||||
}
|
||||
drain_stream(cf, data, stream);
|
||||
}
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue