http: make 416 not fail with resume + CURLOPT_FAILONERRROR

When asked to resume a download, libcurl will convert that to HTTP logic
and if then the entire file is already transferred it will result in a
416 response from the HTTP server. With CURLOPT_FAILONERRROR set in that
scenario, it should *not* lead to an error return.

Updated test 1156, added test 1273

Reported-by: Jonathan Watt
Fixes #6740
Closes #6753
This commit is contained in:
Daniel Stenberg 2021-03-16 14:41:06 +01:00
parent e8e7ef3612
commit 6d176bee59
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 110 additions and 21 deletions

View file

@ -1094,6 +1094,14 @@ static bool http_should_fail(struct Curl_easy *data)
if(httpcode < 400)
return FALSE;
/*
** A 416 response to a resume request is presumably because the file is
** already completely downloaded and thus not actually a fail.
*/
if(data->state.resume_from && data->state.httpreq == HTTPREQ_GET &&
httpcode == 416)
return FALSE;
/*
** Any code >= 400 that's not 401 or 407 is always
** a terminal error