cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: help with pycurl/win32 and HTTP PUT

From: jason kratz <jkratz_at_gmail.com>
Date: Wed, 9 Feb 2005 09:11:17 -0600

I found out some other information using getinfo. I set the
infilesize and this number is 99460 bytes. I checked that with
content_length_upload. getinfo size_upload only returns 96484 so the
full file isn't being transferred and that must be why I'm getting the
400 return code.

Jason

On Wed, 9 Feb 2005 08:47:13 -0600, jason kratz <jkratz_at_gmail.com> wrote:
> Kjetil-
>
> Thanks for the reply. I actually was looking through some of the
> pycurl tests and found something set up in a similar fashion (tho
> using writers) and set up my code pretty much how you did the example
> below. The thing that is strange is that I keep getting:
>
> "<HTML><HEAD><TITLE>Bad request</TITLE></HEAD>
> <BODY><H1>Bad request</H1>
> Your browser sent a query this server could not understand.
> </BODY></HTML>"
>
> It appears to call the read_callback 7 times with a size of 16384.
> That total byte count is larger than the file itself (which is about
> 99kbytes). Once the 7th time is reached I get a pause for several
> seconds before it throws me back that error message.
>
> I have tried sending the same file to the same server with the curl
> command line tool on Windows and it works just fine. I'm not sure
> what I'm doing wrong here because inserting some print statements
> shows that the full file is being read in.
>
> Thanks,
>
> Jason
>
>
> On Wed, 9 Feb 2005 13:10:22 +0100 (CET), Kjetil Jacobsen
> <kjetilja_at_cs.uit.no> wrote:
> > hello,
> >
> > there is some information wrt callbacks and pycurl at
> >
> > http://pycurl.sf.net/doc/callbacks.html
> >
> > in particular, READDATA cannot be used when READFUNCTION is specified.
> > fortunately, this limitation can be overcome by using a class to store the
> > file reference (instead of using READDATA) and then set a class method as
> > the callback function like this:
> >
> > class filereader:
> >
> > def __init__(self, f):
> > self.f = f
> >
> > def read_callback(self, size):
> > return self.f.read(size)
> >
> > import pycurl
> > c = pycurl.Curl()
> > f = filereader(open('somefile'))
> > c.setopt(c.URL, 'http://somehere/')
> > c.setopt(c.READFUNCTION, f.read_callback)
> >
> > ...
> >
> > regards,
> >
> > - kjetil
> >
> > _______________________________________________
> > http://cool.haxx.se/mailman/listinfo/curl-and-python
> >
>
Received on 2005-02-09