diff mbox

bin/pwclient: accept alternate http_proxy forms

Message ID 1482440972-28388-1-git-send-email-yann.morin.1998@free.fr
State Accepted
Headers show

Commit Message

Yann E. MORIN Dec. 22, 2016, 9:09 p.m. UTC
The forms for http_proxy (and the likes) is not very well defined nor
documented in any authoritaive place. However, there are two common
forms:  http://host:port  or  http://host:port/

Currently, the code chokes on the latter (e.g. with
http_proxy=http://127.0.0.1:8080/ ):

    [...]
      File "/usr/lib/python2.7/httplib.py", line 792, in _get_hostport
        raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
    httplib.InvalidURL: nonnumeric port: '8080/'

Chop off any slash character in the port definition to accept the second
form. If there is no '/' in there, it still works.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Stephen Finucane <stephenfinucane@hotmail.com>
---
 patchwork/bin/pwclient | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Finucane Dec. 23, 2016, 11:11 p.m. UTC | #1
On Thu, 2016-12-22 at 22:09 +0100, Yann E. MORIN wrote:
> The forms for http_proxy (and the likes) is not very well defined nor
> documented in any authoritaive place. However, there are two common
> forms:  http://host:port  or  http://host:port/
> 
> Currently, the code chokes on the latter (e.g. with
> http_proxy=http://127.0.0.1:8080/ ):
> 
>     [...]
>       File "/usr/lib/python2.7/httplib.py", line 792, in
> _get_hostport
>         raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
>     httplib.InvalidURL: nonnumeric port: '8080/'
> 
> Chop off any slash character in the port definition to accept the
> second
> form. If there is no '/' in there, it still works.
> 
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Stephen Finucane <stephenfinucane@hotmail.com>

I changed this to use 'rstrip' instead and applied. Thanks :)

Stephen
diff mbox

Patch

diff --git a/patchwork/bin/pwclient b/patchwork/bin/pwclient
index cee8e2c..cef5536 100755
--- a/patchwork/bin/pwclient
+++ b/patchwork/bin/pwclient
@@ -128,7 +128,7 @@  class Transport(xmlrpclib.SafeTransport):
     def make_connection(self, host):
         self.host = host
         if self.proxy:
-            host = self.proxy.split('://', 1)[-1]
+            host = self.proxy.split('://', 1)[-1].split('/')[0]
         if self.credentials:
             host = '@'.join([self.credentials, host])
         if self.https: