PUT with proxy-support

Laszlo Nagy gandalf at shopzeus.com
Fri Aug 26 11:45:39 CEST 2011

Running pycurl-7.19.0/setup.py -q bdist_egg --dist-dir 
> 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 = {

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.

Good luck,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: MozillaEmulator.py
Type: text/x-python
Size: 12093 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20110826/b126545e/attachment.py>

More information about the Python-list mailing list