http2: fix EOF handling on uploads with auth negotiation

- doing a POST with `--digest` does an override on the initial request
  with `Content-Length: 0`, but the http2 filter was unaware of that
  and expected the originally request body. It did therefore not
  send a final DATA frame with EOF flag to the server.
- The fix overrides any initial notion of post size when the `done_send`
  event is triggered by the transfer loop, leading to the EOF that
  is necessary.
- refs #11194. The fault did not happen in testing, as Apache httpd
  never tries to read the request body of the initial request,
  sends the 401 reply and closes the stream. The server used in the
  reported issue however tried to read the EOF and timed out on the
  request.

Reported-by: Aleksander Mazur
Fixes #11194
Cloes #11200
This commit is contained in:
Stefan Eissing 2023-05-24 18:48:16 +02:00 committed by Daniel Stenberg
parent 1fe8de85d3
commit 5c58cb0212
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 138 additions and 18 deletions

View file

@ -1527,10 +1527,8 @@ static CURLcode http2_data_done_send(struct Curl_cfilter *cf,
if(!stream->send_closed) {
stream->send_closed = TRUE;
if(stream->upload_left) {
/* If we operated with unknown length, we now know that everything
* that is buffered is all we have to send. */
if(stream->upload_left == -1)
stream->upload_left = Curl_bufq_len(&stream->sendbuf);
/* we now know that everything that is buffered is all there is. */
stream->upload_left = Curl_bufq_len(&stream->sendbuf);
/* resume sending here to trigger the callback to get called again so
that it can signal EOF to nghttp2 */
(void)nghttp2_session_resume_data(ctx->h2, stream->id);