<br><br><div class="gmail_quote">On Thu, Aug 25, 2011 at 4:48 PM, Thomas Jollans <span dir="ltr"><<a href="mailto:t@jollybox.de">t@jollybox.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On 25/08/11 13:07, Shashwat Anand wrote:<br>
> I want to make a PUT request.<br>
> I need some headers of my own ( certificates etc ) and I need to<br>
> mandatorily use a proxy.<br>
> Also the url is of the form <a href="http://www.xyz.com/abc" target="_blank">http://www.xyz.com/abc</a> and I don't have<br>
> permission to put data<br>
> on <a href="http://www.xyz.com" target="_blank">http://www.xyz.com</a> while I do have permission to put data<br>
> on <a href="http://www.xyz.com/abc" target="_blank">http://www.xyz.com/abc</a><br>
><br>
> I tried httplib, httplib2, urllib2 with no avail.<br>
<br>
</div>What did you try? What problems did you run into?<br>
<br>
I'm sure there is a way in Python, and chances are you were already<br>
close to finding it -- show us what you tried, what actually happened,<br>
including any error messages in full, and what you wanted to happen.<br>
<br>
Thomas<br></blockquote><div><br></div><div>Hi Thomas,</div><div>so one of my tries was:</div><div><br></div><div><div>import urllib</div><div>import urllib2 </div><div>import httplib </div><div>import httplib2</div><div>

<br></div><div>url = '<a href="http://alatheia.zenfs.com/testing/shashwat">http://alatheia.zenfs.com/testing/shashwat</a>'</div><div>body_content = 'CONTENT GOES HERE'</div><div>proxy = '<a href="http://ca-proxy.corp.xyz.com:3128">ca-proxy.corp.xyz.com:3128</a>'</div>

<div><br></div><div>params = {</div><div>    'x-sws-version' : '1.0',</div><div>    'x-sws-access' : 'public',</div><div>    'User-Agent' : 'CacheSystem',</div><div>    'Cache-Control' : 'public',</div>

<div>    'Content-Type' : 'text/plain',</div><div>    'App-Auth' : 'v=1;a=client.alatheia.prod;h=10.16.19.23;t=1316594650;s=AeEYJMMfElN74fnWD3GlXJ4J.1KiQFg--',    }</div><div><br></div><div>

httplib2.debuglevel=4</div><div>h = httplib2.Http(proxy_info = httplib2.ProxyInfo(3, '<a href="http://ca-proxy.corp.xyz.com:3128">ca-proxy.corp.xyz.com:3128</a>', 3128))</div><div>resp, content = h.request(url, "PUT", body=body_content, headers = params) </div>

<div>print resp</div><div>print content </div></div><div><br></div><div>Output:</div><div><br></div><div><div>connect: (<a href="http://alatheia.zenfs.com">alatheia.zenfs.com</a>, 80)</div><div>Traceback (most recent call last):</div>

<div>  File "test.py", line 29, in <module></div><div>    resp, content = h.request(url, "PUT", body=body_content, headers = params) </div><div>  File "/home/y/lib/python2.6/site-packages/httplib2/__init__.py", line 1436, in request</div>

<div>    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)</div><div>  File "/home/y/lib/python2.6/site-packages/httplib2/__init__.py", line 1188, in _request</div>

<div>    (response, content) = self._conn_request(conn, request_uri, method, body, headers)</div><div>  File "/home/y/lib/python2.6/site-packages/httplib2/__init__.py", line 1123, in _conn_request</div><div>    conn.connect()</div>

<div>  File "/home/y/lib/python2.6/site-packages/httplib2/__init__.py", line 786, in connect</div><div>    self.sock.connect(sa)</div><div>  File "/home/y/lib/python2.6/site-packages/httplib2/socks.py", line 381, in connect</div>

<div>    self.__negotiatehttp(destpair[0], destpair[1])</div><div>  File "/home/y/lib/python2.6/site-packages/httplib2/socks.py", line 347, in __negotiatehttp</div><div>    raise HTTPError((statuscode, statusline[2]))</div>

<div>httplib2.socks.HTTPError: (403, 'Tunnel or SSL Forbidden')</div></div><div><br></div><div>The reason I can trace it is because,</div><div>I can use PUT on <a href="http://alatheia.zenfs.com/testing/shashwat">http://alatheia.zenfs.com/testing/shashwat</a> but not on <a href="http://alatheia.zenfs.com/">http://alatheia.zenfs.com/</a> however host is resolved.</div>

<div>Again port 80 is used even when I use specific port (3128, in this case).</div><div><br></div></div>