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 11:24:43 -0600

Here is the curl command line that works:
curl --basic --user <user>:<pasword> --insecure --cacert empty -v -T
30MIN20050201.CSV https://<ip#>/upload/

I have to use the cacert option to get around some bug that appears to
be in the windows version of the command line client.

Here is a simplied put-only version of my code (results are the same
for the bigger version)::

#!/usr/bin/env python

import pycurl
import sys
import os.path

class filereader:

  def __init__(self, f):
       self.f = f

  def read_callback(self, size):
       line = self.f.read(size)
       return line

fr=filereader(open('30MIN20050201.CSV','r'))
fs = os.path.getsize('30MIN20050201.CSV')
c = pycurl.Curl()
c.setopt(pycurl.URL,'https://ip#/upload/30MIN20050201.CSV')
c.setopt(pycurl.SSL_VERIFYPEER,0)
c.setopt(pycurl.SSL_VERIFYHOST,0)
c.setopt(pycurl.HTTPAUTH,pycurl.HTTPAUTH_BASIC)
c.setopt(pycurl.USERPWD,...)
c.setopt(pycurl.READFUNCTION,fr.read_callback)
c.setopt(pycurl.INFILESIZE,int(fs))
c.setopt(pycurl.UPLOAD,1)
c.perform()
print 'SIZE:',c.getinfo(pycurl.SIZE_UPLOAD)
print 'CODE:',c.getinfo(pycurl.RESPONSE_CODE)
print 'CL:',c.getinfo(pycurl.CONTENT_LENGTH_UPLOAD)
print 'RC:',c.getinfo(pycurl.REDIRECT_COUNT)
c.close()
fr.f.close()

This code would seem to be the same as the commandline but its not
working. curl.exe and the libcurl being used by pycurl are both
7.12.3.

Thanks,

Jason

On Wed, 9 Feb 2005 16:19:18 +0100 (CET), Daniel Stenberg
<daniel-curl_at_haxx.se> wrote:
> On Wed, 9 Feb 2005, jason kratz wrote:
>
> > 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.
>
> Perhaps if you show us your python code and the curl command line you used, we
> could spot the problem or help you out where to debug.
>
> --
> Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
> Dedicated custom curl help for hire: http://haxx.se/curl.html
>
Received on 2005-02-09