tool_cb_hdr: allow etag and content-disposition for 3xx reply

- Parse etag and content-disposition headers for 3xx replies.

For example, a server may send a content-disposition filename header
with a redirect reply (3xx) but not with the final response (2xx).
Without this change curl would ignore the server's specified filename
and continue to use the filename extracted from the user-specified URL.

Prior to this change, 75d79a4 had limited etag and content-disposition
to 2xx replies only.

Tests-by: Daniel Stenberg

Reported-by: Morgan Willcock
Fixes https://github.com/curl/curl/issues/13302
Closes #13484
This commit is contained in:
Jay Satiro 2024-04-26 02:29:20 -04:00 committed by Daniel Stenberg
parent cb5c7039e8
commit 85efbb92b8
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 129 additions and 3 deletions

View file

@ -118,8 +118,9 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
long response = 0;
curl_easy_getinfo(per->curl, CURLINFO_RESPONSE_CODE, &response);
if(response/100 != 2)
/* only care about these headers in 2xx responses */
if((response/100 != 2) && (response/100 != 3))
/* only care about etag and content-disposition headers in 2xx and 3xx
responses */
;
/*
* Write etag to file when --etag-save option is given.