-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Actually append "-" to --range #7837
Conversation
This was broken back in 2005 in a93af43#diff-e0cf5b28d9b6b600f0af2bc78e8fd30ec675fd731a5da86f0c4283ffc0e40176L2363 (I noticed this working on curlconverter/curlconverter#303) |
Can you please elaborate on the problem this fixes? |
The HTTP Range header https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range must be in this format (where
i.e. it must have a We can see that $ curl -v --range 200 example.com
Warning: A specified range MUST include at least one dash (-). Appending one
Warning: for you!
* Trying 93.184.216.34...
* TCP_NODELAY set
* Connected to example.com (93.184.216.34) port 80 (#0)
> GET / HTTP/1.1
> Host: example.com
> Range: bytes=200
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Age: 578770
< Cache-Control: max-age=604800
< Content-Type: text/html; charset=UTF-8
< Date: Mon, 11 Oct 2021 09:50:04 GMT
< Etag: "3147526947+ident"
< Expires: Mon, 18 Oct 2021 09:50:04 GMT
< Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
< Server: ECS (sec/973B)
< Vary: Accept-Encoding
< X-Cache: HIT
< Content-Length: 1256
<
<!doctype html>
<html>
<head>
[...] As you can see, curl warned me that
but the actual
and the server just ignores the (invalid) header and returns the whole page
This is because curl adds the Line 1950 in 521bbbe
Line 1952 in 521bbbe
but then overwrites it with the argument exactly as it was passed in on this line Line 1971 in 521bbbe
With the change in this PR, it actually appends the
The header that gets sent is a valid range
and the server responds with the file starting at the 200th byte:
So either curl should actually append the |
Thanks for that, now I'm with you a 100%. I've made a test case locally that reproduces this problem and verifies your PR. |
Thanks! |
Because the block is missing the
else
, it always executes and overwrites the result of theif
block before it. So curl has been warning users that it has fixed their incorrect--range
it but not actually fixing it.