diff options
author | Brad King <brad.king@kitware.com> | 2024-09-18 15:42:10 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-09-18 15:51:18 (GMT) |
commit | ce908c42a37fd56325aff80d2c63a4a811ce9389 (patch) | |
tree | 98319de414b3d57d58a2e7710985b101fcb022e5 /Utilities/cmcurl/lib/http.c | |
parent | 862bd5defc382e6863ef989aac74e0587925b30d (diff) | |
parent | 1a2b208170bd650f328800afd5584a5d056f195d (diff) | |
download | CMake-ce908c42a37fd56325aff80d2c63a4a811ce9389.zip CMake-ce908c42a37fd56325aff80d2c63a4a811ce9389.tar.gz CMake-ce908c42a37fd56325aff80d2c63a4a811ce9389.tar.bz2 |
Merge branch 'upstream-curl' into update-curl
* upstream-curl:
curl 2024-09-18 (7eb8c048)
Diffstat (limited to 'Utilities/cmcurl/lib/http.c')
-rw-r--r-- | Utilities/cmcurl/lib/http.c | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/Utilities/cmcurl/lib/http.c b/Utilities/cmcurl/lib/http.c index cb379e7..f00c803 100644 --- a/Utilities/cmcurl/lib/http.c +++ b/Utilities/cmcurl/lib/http.c @@ -462,16 +462,15 @@ static CURLcode http_perhapsrewind(struct Curl_easy *data, if(abort_upload) { if(upload_remain >= 0) - infof(data, "%s%sclose instead of sending %" - CURL_FORMAT_CURL_OFF_T " more bytes", - ongoing_auth? ongoing_auth : "", - ongoing_auth? " send, " : "", - upload_remain); + infof(data, "%s%sclose instead of sending %" FMT_OFF_T " more bytes", + ongoing_auth? ongoing_auth : "", + ongoing_auth? " send, " : "", + upload_remain); else infof(data, "%s%sclose instead of sending unknown amount " - "of more bytes", - ongoing_auth? ongoing_auth : "", - ongoing_auth? " send, " : ""); + "of more bytes", + ongoing_auth? ongoing_auth : "", + ongoing_auth? " send, " : ""); /* We decided to abort the ongoing transfer */ streamclose(conn, "Mid-auth HTTP and much data left to send"); /* FIXME: questionable manipulation here, can we do this differently? */ @@ -2049,7 +2048,7 @@ static CURLcode http_resume(struct Curl_easy *data, Curl_HttpReq httpreq) CURLcode result; result = Curl_creader_resume_from(data, data->state.resume_from); if(result) { - failf(data, "Unable to resume from offset %" CURL_FORMAT_CURL_OFF_T, + failf(data, "Unable to resume from offset %" FMT_OFF_T, data->state.resume_from); return result; } @@ -2186,9 +2185,8 @@ CURLcode Curl_http_req_complete(struct Curl_easy *data, !Curl_checkheaders(data, STRCONST("Content-Length")))) { /* we allow replacing this header if not during auth negotiation, although it is not very wise to actually set your own */ - result = Curl_dyn_addf(r, - "Content-Length: %" CURL_FORMAT_CURL_OFF_T - "\r\n", req_clen); + result = Curl_dyn_addf(r, "Content-Length: %" FMT_OFF_T "\r\n", + req_clen); } if(result) goto out; @@ -2343,8 +2341,7 @@ CURLcode Curl_http_range(struct Curl_easy *data, remote part so we tell the server (and act accordingly) that we upload the whole file (again) */ data->state.aptr.rangeline = - aprintf("Content-Range: bytes 0-%" CURL_FORMAT_CURL_OFF_T - "/%" CURL_FORMAT_CURL_OFF_T "\r\n", + aprintf("Content-Range: bytes 0-%" FMT_OFF_T "/%" FMT_OFF_T "\r\n", req_clen - 1, req_clen); } @@ -2357,15 +2354,14 @@ CURLcode Curl_http_range(struct Curl_easy *data, data->state.infilesize : (data->state.resume_from + req_clen); data->state.aptr.rangeline = - aprintf("Content-Range: bytes %s%" CURL_FORMAT_CURL_OFF_T - "/%" CURL_FORMAT_CURL_OFF_T "\r\n", + aprintf("Content-Range: bytes %s%" FMT_OFF_T "/%" FMT_OFF_T "\r\n", data->state.range, total_len-1, total_len); } else { /* Range was selected and then we just pass the incoming range and append total size */ data->state.aptr.rangeline = - aprintf("Content-Range: bytes %s/%" CURL_FORMAT_CURL_OFF_T "\r\n", + aprintf("Content-Range: bytes %s/%" FMT_OFF_T "\r\n", data->state.range, req_clen); } if(!data->state.aptr.rangeline) @@ -3118,7 +3114,7 @@ CURLcode Curl_http_header(struct Curl_easy *data, #ifdef DEBUGBUILD else infof(data, "Parsed STS header fine (%zu entries)", - data->hsts->list.size); + Curl_llist_count(&data->hsts->list)); #endif } #endif @@ -3154,6 +3150,11 @@ CURLcode Curl_http_header(struct Curl_easy *data, } return CURLE_OK; } + v = HD_VAL(hd, hdlen, "Trailer:"); + if(v) { + data->req.resp_trailer = TRUE; + return CURLE_OK; + } break; case 'w': case 'W': @@ -3241,9 +3242,6 @@ CURLcode Curl_http_statusline(struct Curl_easy *data, else if(k->httpversion == 20 || (k->upgr101 == UPGR101_H2 && k->httpcode == 101)) { DEBUGF(infof(data, "HTTP/2 found, allow multiplexing")); - /* HTTP/2 cannot avoid multiplexing since it is a core functionality - of the protocol */ - conn->bundle->multiuse = BUNDLE_MULTIPLEX; } k->http_bodyless = k->httpcode >= 100 && k->httpcode < 200; @@ -3285,10 +3283,13 @@ CURLcode Curl_http_size(struct Curl_easy *data) } else if(k->size != -1) { if(data->set.max_filesize && - k->size > data->set.max_filesize) { + !k->ignorebody && + (k->size > data->set.max_filesize)) { failf(data, "Maximum file size exceeded"); return CURLE_FILESIZE_EXCEEDED; } + if(k->ignorebody) + infof(data, "setting size while ignoring"); Curl_pgrsSetDownloadSize(data, k->size); k->maxdownload = k->size; } @@ -3393,9 +3394,6 @@ static CURLcode http_on_response(struct Curl_easy *data, if(conn->httpversion != 20) infof(data, "Lying server, not serving HTTP/2"); } - if(conn->httpversion < 20) { - conn->bundle->multiuse = BUNDLE_NO_MULTIUSE; - } if(k->httpcode < 200 && last_hd) { /* Intermediate responses might trigger processing of more @@ -3440,6 +3438,7 @@ static CURLcode http_on_response(struct Curl_easy *data, /* Switching to HTTP/2, where we will get more responses */ infof(data, "Received 101, Switching to HTTP/2"); k->upgr101 = UPGR101_RECEIVED; + data->conn->bits.asks_multiplex = FALSE; /* We expect more response from HTTP/2 later */ k->header = TRUE; k->headerline = 0; /* restart the header line counter */ @@ -3486,6 +3485,7 @@ static CURLcode http_on_response(struct Curl_easy *data, if(k->upgr101 == UPGR101_H2) { /* A requested upgrade was denied, poke the multi handle to possibly allow a pending pipewait to continue */ + data->conn->bits.asks_multiplex = FALSE; Curl_multi_connchanged(data->multi); } @@ -3535,7 +3535,7 @@ static CURLcode http_on_response(struct Curl_easy *data, #endif #ifdef USE_WEBSOCKETS - /* All >=200 HTTP status codes are errors when wanting websockets */ + /* All >=200 HTTP status codes are errors when wanting WebSockets */ if(data->req.upgr101 == UPGR101_WS) { failf(data, "Refused WebSockets upgrade: %d", k->httpcode); result = CURLE_HTTP_RETURNED_ERROR; @@ -3628,13 +3628,6 @@ static CURLcode http_on_response(struct Curl_easy *data, } - /* This is the last response that we will got for the current request. - * Check on the body size and determine if the response is complete. - */ - result = Curl_http_size(data); - if(result) - goto out; - /* If we requested a "no body", this is a good time to get * out and return home. */ @@ -3654,6 +3647,12 @@ static CURLcode http_on_response(struct Curl_easy *data, /* final response without error, prepare to receive the body */ result = Curl_http_firstwrite(data); + if(!result) + /* This is the last response that we get for the current request. + * Check on the body size and determine if the response is complete. + */ + result = Curl_http_size(data); + out: if(last_hd) { /* if not written yet, write it now */ @@ -4431,9 +4430,18 @@ static CURLcode cr_exp100_read(struct Curl_easy *data, switch(ctx->state) { case EXP100_SENDING_REQUEST: + if(!Curl_req_sendbuf_empty(data)) { + /* The initial request data has not been fully sent yet. Do + * not start the timer yet. */ + DEBUGF(infof(data, "cr_exp100_read, request not full sent yet")); + *nread = 0; + *eos = FALSE; + return CURLE_OK; + } /* We are now waiting for a reply from the server or - * a timeout on our side */ - DEBUGF(infof(data, "cr_exp100_read, start AWAITING_CONTINUE")); + * a timeout on our side IFF the request has been fully sent. */ + DEBUGF(infof(data, "cr_exp100_read, start AWAITING_CONTINUE, " + "timeout %ldms", data->set.expect_100_timeout)); ctx->state = EXP100_AWAITING_CONTINUE; ctx->start = Curl_now(); Curl_expire(data, data->set.expect_100_timeout, EXPIRE_100_TIMEOUT); |