curl-and-python

Re: Getting range error although the server accepts range

From: naheed arafat <naheedcse_at_gmail.com>
Date: Thu, 19 Dec 2013 22:53:09 +0600

On Thu, Dec 19, 2013 at 1:45 AM, Dima Tisnek <dimaqq_at_gmail.com> wrote:

> enable debug, validate request header fields.
>
> just in case of multiple dns entries, make sure same ip address is
> connected to.
>
>
Could you please explain why i need to ensure that? and how i can ensure
that in my code?

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
>
>
Yes, The header was different from the command line tool.
In response to the range request the command line tool gets 206 Partial
Content but pycurl code gets 200 OK response. The content-length field is
also different. I tried-

In the command line:

curl -v -r 0-10 http://cache1.tinyvid.net/otaku/3237ep5-Dragon_Ball_Z.mp4

The code:

import pycurl
import cStringIO
url="http://cache1.tinyvid.net/otaku/3237ep5-Dragon_Ball_Z.mp4"
def test(debug_type, debug_msg):
     if debug_type!=3:
        print "debug(%d): %s" % (debug_type, debug_msg)

c=pycurl.Curl()
c.setopt(pycurl.URL,url)
c.setopt(c.VERBOSE,True)
c.setopt(pycurl.DEBUGFUNCTION, test)
c.setopt(pycurl.FOLLOWLOCATION,0)
c.setopt(pycurl.NOPROGRESS,0)
c.setopt(c.NOBODY, 1)
header = cStringIO.StringIO()
c.setopt(c.HEADERFUNCTION, header.write)
c.setopt(pycurl.RANGE,"0-10")
try:
c.perform()
except pycurl.error,e:
print e

Any idea why they are different?

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2013-12-19