Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
curl appends error messages for 416 status code from server to the downloaded file with option "-C -" #1163
I did this
There is a file of size 100 bytes on HTTP server(nginx).
File size grew to 322 bytes!
I expected the following
I expects that curl ignores body of HTTP response when its status code is 416 as wget behaves
curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
Linux comp-ppl-fs03 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
The only way I think that could happen is if the 416 returns a Content-Range. I don't recall offhand if that's allowed. Run curl in verbose mode to confirm.
A server could also return a 404 not found as a 216 partial , I think, so in that case you would also end up with bad appended data in your file. I don't know the best solution for that (or any solution, actually..), but in the 416 case I think you should use
Thanks for you comment.
According to RFC 7233, Content-Range should be added to the response with 416.
And at least nginx does:
I think curl should handle 416 with Content-Range: */100 as OK and discard body part for the request with Range: 100-.
I agree, the only sane action seems to be, at least to me, handling the 416 by NOT writing the output to the file and then perhaps returning an error code. Is there any use case where the current action is valid? Any circumstance where a 416 would be returned with the remaining content? I wouldn't have thought so.
The 416 is omitted on purpose, looking at the code:
I am experiencing this issue as well.
It affects the use of curl with the webserver embedded in the Goluk T series of dashcams, which is nginx 1.9.6 and some sort of (unknown/undocumented) custom CGI.
The first attempt:
Successfully downloads the file.
Every subsequent attempt with the same commandline results in the following being appended to the file: