PUT with proxy-support

Shashwat Anand anand.shashwat at gmail.com
Fri Aug 26 08:51:54 EDT 2011

On Fri, Aug 26, 2011 at 3:15 PM, Laszlo Nagy <gandalf at shopzeus.com> wrote:

> Running pycurl-7.19.0/setup.py -q bdist_egg --dist-dir
> /tmp/easy_install-2ZCa8v/**pycurl-7.19.0/egg-dist-tmp-**DyHFls
>> Using curl-config (libcurl 7.12.1)
>> src/pycurl.c:42:20: Python.h: No such file or directory
>> src/pycurl.c:43:22: pythread.h: No such file or directory
>> src/pycurl.c:58:4: #error "Need Python version 2.2 or greater to compile
>> pycurl."
>> src/pycurl.c:61:4: #error "Need libcurl version 7.19.0 or greater to
>> compile pycurl."
>> [... Error Clipped]
>> error: Setup script exited with error: command '/usr/bin/gcc' failed with
>> exit status 1
> I'm not familiar with red hat. But looks like this is now a sysadmin
> problem. I could install pycurl under freebsd and ubuntu too.
> I have some code that might be able to PUT through a proxy for you. Please
> look at the attached file.
> You can setup a proxy this way:
> import MozzillaEmulator
> MozzillaEmulator.DEFAULT_**PROXIES = {
>    'http':'http://user:password@**proxy.host.com:3128<http://user:password@proxy.host.com:3128>
> ',
>    'https':'http://user:password@**proxy.host.com:3128<http://user:password@proxy.host.com:3128>
> ',
> }
> And here is how you use it:
> dl = MozillaEmulator.**MozillaEmulator()
> put_url = "http://some_url_to_put_to"
> headers = {'Content-Type':'application/**xml;charset=UTF-8'}
> data = open("some_file","rb").read()
> response =  dl.download(put_url,data,**headers,put_method=True)
> If you don't set the put_method flag, then it will POST instead. (But in
> that case, post data must be a valid post data field fields and values.) If
> you don't give post_data then it will GET. The PUT method was tested without
> a proxy, and the GET and POST methods were tested with and without proxy.
> Actually I have tried to do PUT through a proxy, but it didn't work. But it
> was a restriction on the proxy side. (As far as I can recall, the error
> message came from the proxy server, something about unsupported request?).
> So it *might* work for you, with the right proxy server that supports PUT
> requests.
> Also be aware that this version uses urllib2. Although it can use https
> protocol, it doesn't check the server's certificate.
Mozilla Emulator works like a charm.
Also managed to install pycurl and the same works too.

Thanks. :)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110826/3be7ff5d/attachment.html>

More information about the Python-list mailing list