curl-and-python
Re: Getting range error although the server accepts range
Date: Wed, 18 Dec 2013 20:45:32 +0100
enable debug, validate request header fields.
just in case of multiple dns entries, make sure same ip address is connected to.
command line curl(*) range seems to work:
curl -v -r 1-10 http://cache1.tinyvid.net/otaku/3237ep5-Dragon_Ball_Z.mp4
curl -v -r 54513380- http://cache1.tinyvid.net/otaku/3237ep5-Dragon_Ball_Z.mp4
thus, check if the request header fields ultimately generated by your
programs are any different than command line tool
(*) curl 7.30.0 (x86_64-apple-darwin13.0) libcurl/7.30.0
SecureTransport zlib/1.2.5
On 18 December 2013 20:21, naheed <naheedcse_at_gmail.com> wrote:
> Hi there
> I am trying to build a simple video downloader with pause-resume
> functionality. I checked whether the server supports partial download by a
> HEAD request. I got the following response:
>
>> HEAD /otaku/3237ep5-Dragon_Ball_Z.mp4 HTTP/1.1
> User-Agent: PycURL/7.22.0
> Host: cache1.tinyvid.net
> Accept: */*
>
> < HTTP/1.1 200 OK
> < Server: cloudflare-nginx
> < Date: Wed, 18 Dec 2013 18:49:25 GMT
> < Content-Type: video/mp4
> < Content-Length: 54513381
> < Connection: close
> < Set-Cookie: __cfduid=da4f69981ffbbfeaac12d30299520be451387392564744;
> expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.tinyvid.net; HttpOnly
> < Last-Modified: Mon, 26 Nov 2012 09:59:58 GMT
> < Accept-Ranges: bytes
> < CF-RAY: dee0869a7b3082f
> <
>
> Seeing that the server accepts byte range- The following code runs fine
> first time. But when run second time it raises range error ("HTTP server
> doesn't seem to support byte ranges. Cannot resume."), although it should
> have resumed from the byte i last downloaded.
>
> import pycurl
> import os
> import sys
> url="http://cache1.tinyvid.net/otaku/3237ep5-Dragon_Ball_Z.mp4"
> c=pycurl.Curl()
> c.setopt(pycurl.URL,url)
> c.setopt(pycurl.FOLLOWLOCATION,0)
> c.setopt(pycurl.NOPROGRESS,0)
> filename = url.split("/")[-1].strip()
> filepath = os.path.join(os.getcwd(), filename)
> if os.path.exists(filepath):
> f = open(filepath, "ab")
> downloaded = os.path.getsize(filepath)
> c.setopt(pycurl.RESUME_FROM, downloaded)
> else:
> f = open(filepath, "wb")
> c.setopt(pycurl.WRITEDATA, f)
> try:
> c.perform()
> except pycurl.error,e:
> print e
> c.close()
>
> Am i missing something basic? Some help in this regard would be really
> helpful.
>
> Regards,
> Naheed Anjum Arafat
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2013-12-18