gesomax / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

Http.request fails accesing Google account via http proxy #54

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. run attached program. It requires 4 arguments: Your google account,
password, proxy_host, proxy port

What is the expected output? What do you see instead?
Expected output - some XML representation of Google calendar
Real output  - exception at line:

  self.sock.setproxy(*self.proxy_info.astuple())

in the method HTTPSConnectionWithTimeout.connect
self.sock is not set at the moment of connection, so no methos can be
called on it.

What version of the product are you using? On what operating system?
httplib2-0.4.0, ubuntu-9.04, suse-10.3

Original issue reported on code.google.com by Alexande...@googlemail.com on 7 May 2009 at 2:23

Attachments:

GoogleCodeExporter commented 8 years ago
Look like that class HTTPSConnectionWithTimeout simply cannot work with any 
proxy

just:
h=httplib2.HTTPSConnectionWithTimeout(proxy_info=p)
h.connect()
will always fail because inside method 
'httplib2.HTTPSConnectionWithTimeout.connect'
calls 'setproxy' on self.sock which was never initialized.

Original comment by Alexande...@googlemail.com on 8 May 2009 at 7:15

GoogleCodeExporter commented 8 years ago
Solution of problem is simple:
Peplace:
        if self.proxy_info and self.proxy_info.isgood():
            self.sock.setproxy(*self.proxy_info.astuple())
            sock.setproxy(*self.proxy_info.astuple())
with:
        if self.proxy_info and self.proxy_info.isgood():
            sock = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM)
            sock.setproxy(*self.proxy_info.astuple())

In method HTTPSConnectionWithTimeout.connect

Original comment by Alexande...@googlemail.com on 8 May 2009 at 7:38

GoogleCodeExporter commented 8 years ago
OK. I format suggested correction as a patch.
May be it helps...

Original comment by Alexande...@googlemail.com on 13 May 2009 at 7:10

Attachments:

GoogleCodeExporter commented 8 years ago
Fixed in trunk.

Original comment by joe.gregorio@gmail.com on 28 Jul 2009 at 2:49