cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: The end-range is out of the range of the file, but curl doesn't care it.

From: Hongyi Zhao <hongyi.zhao_at_gmail.com>
Date: Wed, 29 Apr 2015 13:48:50 +0800

2015-04-28 16:02 GMT+08:00 Daniel Stenberg <daniel_at_haxx.se>:
> On Tue, 28 Apr 2015, Hongyi Zhao wrote:
>
>> As you can see, the end-range is out of the range of the file, but curl
>> still treat is as the successfully execution.
>
>
> It does the same for an HTTP range:
>
> $ curl -r 5-202 localhost -v
>>
>> GET / HTTP/1.1
>> Host: localhost
>> Range: bytes=5-202
>> User-Agent: curl/7.42.0
>> Accept: */*
>>
> < HTTP/1.1 206 Partial Content
> < Date: Tue, 28 Apr 2015 08:00:04 GMT
> < Server: Apache/2.4.10 (Debian)
> < Last-Modified: Sat, 31 May 2014 22:05:33 GMT
> < ETag: "d-4fab95c704b1c"
> < Accept-Ranges: bytes
> < Content-Length: 8
> < Content-Range: bytes 5-12/13
> < Content-Type: text/html
> <
> tinken
> * Connection #0 to host localhost left intact
> $ echo $?
> 0
>
>> Any hints?
>
>
> You mean you'd like that to fail? Can you motivate that?

But, see the followint testings for my case:

werner_at_debian:~$ curl -r 200-202 localhost -v 1> /dev/null
[snip]
< HTTP/1.1 416 Requested Range Not Satisfiable
[snip]

werner_at_debian:~$ echo $?
0

In the above case, the rquested range is completely out of the range.
Why curl still return will 0?

While for a local file, curl will return 36 if the rquested range is
completely out of the range, see the following:

werner_at_debian:~$ echo "hello world" > fnord
werner_at_debian:~$ curl -r 50-100 file://$PWD/fnord
curl: (36) failed to resume file:// transfer
werner_at_debian:~$ echo $?
36

In addition, I've posted another thread on this list with the name
"Requested range is entirely out of the file, but curl still return
with exit status of 0." for this issue.

Regards

>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-users
> FAQ: http://curl.haxx.se/docs/faq.html
> Etiquette: http://curl.haxx.se/mail/etiquette.html

-- 
Hongyi Zhao <hongyi.zhao_at_gmail.com>
Xinjiang Technical Institute of Physics and Chemistry
Chinese Academy of Sciences
GnuPG DSA: 0xD108493
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2015-04-29