Merge lp:~vila/bzr/186920-lp-proxy into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~vila/bzr/186920-lp-proxy
Merge into: lp:bzr
Diff against target: 26 lines
1 file modified
bzrlib/transport/http/_urllib2_wrappers.py (+10/-7)
To merge this branch: bzr merge lp:~vila/bzr/186920-lp-proxy
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+14362@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

While making things work for lp (which use the default 443 port for https),
the previous patch wasn't correct for non-default ports.

Manual tests showed that some proxies (at least tinyproxy)
will work even, when connecting to an https server running on localhost:25019
by issuing:

    CONNECT localhost:25019:443 HTTP/1.1

and ignoring the additional :443...

This patch will, instead, correctly issue:

    CONNECT localhost:25019

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vincent Ladeuil wrote:
> Vincent Ladeuil has proposed merging lp:~vila/bzr/186920-lp-proxy into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
>
>
> While making things work for lp (which use the default 443 port for https),
> the previous patch wasn't correct for non-default ports.
>
> Manual tests showed that some proxies (at least tinyproxy)
> will work even, when connecting to an https server running on localhost:25019
> by issuing:
>
> CONNECT localhost:25019:443 HTTP/1.1
>
> and ignoring the additional :443...
>
> This patch will, instead, correctly issue:
>
> CONNECT localhost:25019

What, no tests? :)

So it seems that 'get_host()' already has the port number. It seems a
little strange to forcibly split it just to put it back together. What
about this:

self.proxied_host = self.get_host()
host, port = urllib.splitport(self.proxied_host)
if port is None:
  # We always need to have a :port when going through some proxies, so
  # set it to the default port here
  if self.type == 'https':
    conn_class = HTTPSConnection
  else:
    ...
  self.proxied_host = '%s:%s' % (host, conn_class.default_port)

Anyway, it doesn't really matter.

  review: approve
  merge: approve

Either way.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrwQHQACgkQJdeBCYSNAAPERwCfaPZWtWs/up8B3HA9mW6N0OrZ
0X0AoKYIlGrFl+qiH/9X6xj5VFnDYFwG
=/rOT
-----END PGP SIGNATURE-----

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
3--- bzrlib/transport/http/_urllib2_wrappers.py 2009-10-30 21:02:37 +0000
4+++ bzrlib/transport/http/_urllib2_wrappers.py 2009-11-03 14:20:31 +0000
5@@ -366,13 +366,16 @@
6
7 def set_proxy(self, proxy, type):
8 """Set the proxy and remember the proxied host."""
9- # We need to set the default port ourselves way before it gets set
10- # in the HTTP[S]Connection object at build time.
11- if self.type == 'https':
12- conn_class = HTTPSConnection
13- else:
14- conn_class = HTTPConnection
15- self.proxied_host = '%s:%s' % (self.get_host(), conn_class.default_port)
16+ host, port = urllib.splitport(self.get_host())
17+ if port is None:
18+ # We need to set the default port ourselves way before it gets set
19+ # in the HTTP[S]Connection object at build time.
20+ if self.type == 'https':
21+ conn_class = HTTPSConnection
22+ else:
23+ conn_class = HTTPConnection
24+ port = conn_class.default_port
25+ self.proxied_host = '%s:%s' % (host, port)
26 urllib2.Request.set_proxy(self, proxy, type)
27
28