kartagis / pysimplesoap

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

client unable to use urllib2 properly #38

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a simple client:

c = SoapClient(wsdl=..., trace=True)
c.method()

What is the expected output? What do you see instead?
Fetching the WSDL file fails using urllib2. I do not have httplib2 installed.

What version of the product are you using? On what operating system?
Python 2.6 on Windows.

Please provide any additional information below.
2 bugs:
1. SoapClient creates HTTP wrapper using Http(timeout=TIMEOUT) and the default 
timeout is 60, which urllib2Transport complains with "timeout not supported"

2. SoapClient.fetch(url) calls the HTTP wrapper with self.http.request(url, 
"GET") which complains because urllib2Transport has 5 mandatory args, but is 
called only with 2.

The following patch should fix the bugs:

diff --git a/pysimplesoap/client.py b/pysimplesoap/client.py
--- a/pysimplesoap/client.py
+++ b/pysimplesoap/client.py
@@ -42,6 +42,7 @@
 try:
     import httplib2
 except ImportError:
+    TIMEOUT = None # timeout not supported by urllib2
     pass
 else:
     class Httplib2Transport(httplib2.Http, TransportBase):
@@ -91,7 +92,7 @@
             opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(CookieJar()))
             self.request_opener = opener.open

-    def request(self, url, method, body, headers):
+    def request(self, url, method="GET", body=None, headers={}):
         try:
             f = self.request_opener(urllib2.Request(url, body, headers))
         except urllib2.HTTPError, f:

Original issue reported on code.google.com by darell....@gmail.com on 6 Nov 2011 at 9:06

GoogleCodeExporter commented 8 years ago
Thanks, would you like to patch the file?
(I've given you commit access)

Original comment by reingart@gmail.com on 7 Nov 2011 at 3:18

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 3cf15c5879bc.

Original comment by darell....@gmail.com on 7 Nov 2011 at 4:03

GoogleCodeExporter commented 8 years ago
This bug reappeared! It is in version 1.05a and current revision from the 
default branch.

The TIMEOUT constant in transport.py is correctly changed to None but is never 
used.

The TIMEOUT constant in client.py is not changed to None but is used, leading 
to the bug.

Original comment by remi.k2...@gmail.com on 8 May 2012 at 6:48