summaryrefslogtreecommitdiff
path: root/lib/c-hyper.c
diff options
context:
space:
mode:
authorJay Satiro <raysatiro@yahoo.com>2021-10-01 13:57:23 -0400
committerJay Satiro <raysatiro@yahoo.com>2021-10-15 03:40:16 -0400
commitb1d08d295f0e5035f9772654533f3caab64dd8c7 (patch)
tree7613054088e28118bdf11a61861a34207976aa0f /lib/c-hyper.c
parent8c6f126279f8abddf76661d0b404162c15bcc2c2 (diff)
downloadcurl-b1d08d295f0e5035f9772654533f3caab64dd8c7.tar.gz
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 in 8a16e54 (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: https://github.com/curl/curl/commit/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
Diffstat (limited to 'lib/c-hyper.c')
-rw-r--r--lib/c-hyper.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/c-hyper.c b/lib/c-hyper.c
index bc3f82135..7ce958adb 100644
--- a/lib/c-hyper.c
+++ b/lib/c-hyper.c
@@ -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'