mirror of
https://github.com/curl/curl.git
synced 2026-08-25 14:23:39 +03:00
http: set content length earlier
- Make content length (ie download size) accessible to the user in the header callback, but only after all headers have been processed (ie only in the final call to the header callback). Background: For a long time the content length could be retrieved in the header callback via CURLINFO_CONTENT_LENGTH_DOWNLOAD_T as soon as it was parsed by curl. Changes were made in8a16e54(precedes 7.79.0) to ignore content length if any transfer encoding is used. A side effect of that was that content length was not set by libcurl until after the header callback was called the final time, because until all headers are processed it cannot be determined if content length is valid. This change keeps the same intention --all headers must be processed-- but now the content length is available before the final call to the header function that indicates all headers have been processed (ie a blank header). Bug:8a16e54 (r57374914)Reported-by: sergio-nsk@users.noreply.github.com Co-authored-by: Daniel Stenberg Fixes https://github.com/curl/curl/issues/7804 Closes https://github.com/curl/curl/pull/7803
This commit is contained in:
parent
8c6f126279
commit
b1d08d295f
3 changed files with 41 additions and 45 deletions
|
|
@ -299,8 +299,14 @@ static CURLcode status_line(struct Curl_easy *data,
|
|||
*/
|
||||
static CURLcode empty_header(struct Curl_easy *data)
|
||||
{
|
||||
return hyper_each_header(data, NULL, 0, NULL, 0) ?
|
||||
CURLE_WRITE_ERROR : CURLE_OK;
|
||||
CURLcode result = Curl_http_size(data);
|
||||
if(!result) {
|
||||
result = hyper_each_header(data, NULL, 0, NULL, 0) ?
|
||||
CURLE_WRITE_ERROR : CURLE_OK;
|
||||
if(result)
|
||||
failf(data, "hyperstream: couldn't pass blank header");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
CURLcode Curl_hyper_stream(struct Curl_easy *data,
|
||||
|
|
@ -443,11 +449,9 @@ CURLcode Curl_hyper_stream(struct Curl_easy *data,
|
|||
break;
|
||||
}
|
||||
|
||||
if(empty_header(data)) {
|
||||
failf(data, "hyperstream: couldn't pass blank header");
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
result = empty_header(data);
|
||||
if(result)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Curl_http_auth_act() checks what authentication methods that are
|
||||
* available and decides which one (if any) to use. It will set 'newurl'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue