[jplouis@zenoss.com: Fwd: https proxy CONNECT patch]

13 views
Skip to first unread message

C. Titus Brown

unread,
Mar 30, 2009, 5:14:15 PM3/30/09
to twill-dev
----- Forwarded message from Jean-Pierre Louis <jpl...@zenoss.com> -----

From: Jean-Pierre Louis <jpl...@zenoss.com>
To: ti...@idyll.org
Subject: Fwd: https proxy CONNECT patch
Date: Mon, 9 Mar 2009 10:25:37 -0500
X-Mailer: Apple Mail (2.930.3)

Begin forwarded message:

>From: twill...@lists.idyll.org
>Date: March 9, 2009 10:24:25 AM CDT
>To: jpl...@zenoss.com
>Subject: https proxy CONNECT patch
>
>I'm sorry, for spam reasons, I've disabled posting from non-members.
>Please send your post directly to ti...@idyll.org and I will post it,
>OR just subscribe to the list and send your message directory.
>
>thanks, --titus
>
>
>From: Jean-Pierre Louis <jpl...@zenoss.com>
>Date: March 9, 2009 10:24:03 AM CDT
>To: tw...@lists.idyll.org
>Subject: https proxy CONNECT patch
>
>
>Even after installing the httpsproxy_urllib2 fix from
>http://pypi.python.org/pypi/httpsproxy_urllib2 to our python 2.4.4
> environment, Twill wasn't working properly with proxies when trying to
>connect to https sites. CONNECT messages were not being sent to the
>proxy.
>
>I made some change to some of the mechanize files so that it would
>work with httpsproxy_urllib2. These changes were changes present in
>their corresponding httpsproxy_urllib2 versions. The fix requires
>the httpsproxy_urllib2 update.
>
>For legacy reasons we are using .9b1, but I couldn't get it proxy
>CONNECT to work with the .9 version either, this change should work
>on .9 as well.
>
>
>
>--- twill-0.9b1/twill/other_packages/_mechanize_dist/_auth.py
>2007-09-26 03:05:17.000000000 -0500
>+++ twill/other_packages/_mechanize_dist/_auth.py 2009-02-18
>15:30:39.000000000 -0600
>@@ -115,7 +115,7 @@
> req.add_header('Proxy-authorization', 'Basic ' + creds)
> hostport = unquote(hostport)
> req.set_proxy(hostport, proxy_type)
>- if orig_type == proxy_type:
>+ if orig_type == proxy_type or orig_type == 'https':
> # let other handlers take care of it
> return None
> else:
>
>--- twill-0.9b1/twill/other_packages/_mechanize_dist/_http.py
>2007-09-26 03:05:18.000000000 -0500
>+++ twill/other_packages/_mechanize_dist/_http.py 2009-02-18
>15:12:21.000000000 -0600
>@@ -630,6 +630,10 @@
> request.add_unredirected_header(
> 'Content-type',
> 'application/x-www-form-urlencoded')
>+ if not request.has_header('Content-length'):
>+ request.add_unredirected_header(
>+ 'Content-length', '%d' % len(data))
>+
>
> scheme, sel = urllib.splittype(request.get_selector())
> sel_host, sel_path = urllib.splithost(sel)
>@@ -670,6 +674,8 @@
> headers["Connection"] = "close"
> headers = dict(
> [(name.title(), val) for name, val in headers.items()])
>+ if req._tunnel_host:
>+ h.set_tunnel(req._tunnel_host)
> try:
> h.request(req.get_method(), req.get_selector(),
>req.data, headers)
> r = h.getresponse()
>
>


----- End forwarded message -----

--
C. Titus Brown, c...@msu.edu

Reply all
Reply to author
Forward
0 new messages