curl-and-python

Re: FTP upload through HTTP proxy

From: Kjetil Jacobsen <kjetilja_at_gmail.com>
Date: Wed, 8 Aug 2007 09:14:49 +0200

hello!

have you tried using the --libcurl option with curl? this will give
you a source file in c which corresponds to the command line you
specified when running curl. from this source file you should be able
to see which curl options have been set for for corresponding curl
command line.

example usage:
  curl http://curl.haxx.se/ --libcurl output.c

regards,
    - kjetil

On 8/8/07, Kumar Appaiah <kumar.appaiah_at_gmail.com> wrote:
> Dear pycURL users,
>
> I wish to upload to an FTP server through a HTTP proxy. Now, curl
> works fine with the following (after the proxy environment variable is
> set):
>
> curl --verbose -T file "ftp://username:password@ftp.myftp.com"
>
> How do I put it into pycurl code? The following gives me a (56,
> 'Received HTTP code 403 from proxy after CONNECT') error:
>
> import pycurl
> import getpass
> c = pycurl.Curl()
> c.setopt(pycurl.FOLLOWLOCATION, 1)
> c.setopt(pycurl.UPLOAD, True)
> c.setopt(pycurl.URL, "ftp://username:" + getpass.getpass() + "@ftp.myftp.com")
> c.setopt(pycurl.PROXY, "http://myproxy")
> c.setopt(pycurl.HTTPPROXYTUNNEL, True)
> f = open("watch", 'r')
> c.setopt(pycurl.READDATA, f)
> f.close()
> c.perform()
> print b.getvalue()
>
> And the same environment variables are set. Any pointers?
>
> Thanks.
>
> Kumar
> --
> Kumar Appaiah,
> 458, Jamuna Hostel,
> Indian Institute of Technology Madras,
> Chennai - 600036
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2007-08-08