[Fedora-suds-list] Fw: HttpAuthenticated over vanilla HTTP connection fixed.

nicolas.stinus at externe.bnpparibas.com nicolas.stinus at externe.bnpparibas.com
Tue Jul 13 14:47:21 UTC 2010


Hello,

Sorry but, the previous patch was not working...
This one, quite rough around the edges, solved (really) the thing:

diff --git a/suds/client.py b/suds/client.py
index b91a7da..a720f33 100644
--- a/suds/client.py
+++ b/suds/client.py
@@ -25,7 +25,8 @@ from cookielib import CookieJar
 from suds import *
 from suds.reader import DefinitionsReader
 from suds.transport import TransportError, Request
-from suds.transport.https import HttpAuthenticated
+from suds.transport.http import HttpAuthenticated
+from suds.transport.https import HttpAuthenticated as HttpsAuthenticated
 from suds.servicedefinition import ServiceDefinition
 from suds import sudsobject
 from sudsobject import Factory as InstFactory
diff --git a/suds/transport/http.py b/suds/transport/http.py
index 6d85b09..5e1556e 100644
--- a/suds/transport/http.py
+++ b/suds/transport/http.py
@@ -58,6 +58,8 @@ class HttpTransport(Transport):
             url = request.url
             log.debug('opening (%s)', url)
             u2request = u2.Request(url)
+            for k, v in request.headers.iteritems():
+                u2request.add_header(k, v)
             self.proxy = self.options.proxy
             return self.u2open(u2request)
         except u2.HTTPError, e:

I'll let you decide whata proper interface to make.

nicolas
----- Réacheminé par Nicolas STINUS/FR/EUROPE/GROUP le 07/13/2010 04:44 PM 
-----

Nicolas STINUS
Assistant Extérieur
AQS Support
Tel: +33 (0) 1 574 37 380
07/13/2010 04:37 PM

Pour
fedora-suds-list at redhat.com
cc

Objet
HttpAuthenticated over vanilla HTTP connection fixed.





Hello,

I've tried to use suds for an internal project which required a Http Basic 
Authentication to be set up over an unencrypted Http connection (!).
It seems like this wasn't covered in suds.

Especially, HttpAuthenticated is always the one in the transport.https 
module.
Changing to the right module, it looked to me like it didn't set the 
headers for authentication.

You'll probbly discard such mistyped quickfix, however it now does the job 
for me.

Here's my diff:

diff --git a/suds/client.py b/suds/client.py
index b91a7da..a8b48d8 100644
--- a/suds/client.py
+++ b/suds/client.py
@@ -25,7 +25,8 @@ from cookielib import CookieJar
 from suds import *
 from suds.reader import DefinitionsReader
 from suds.transport import TransportError, Request
-from suds.transport.https import HttpAuthenticated
+from suds.transport.http import HttpAuthenticated
+from suds.transport.https import HttpAuthenticated as HttpsAuthenticated
 from suds.servicedefinition import ServiceDefinition
 from suds import sudsobject
 from sudsobject import Factory as InstFactory
@@ -103,7 +104,10 @@ class Client(object):
         @see: L{Options}
         """
         options = Options()
-        options.transport = HttpAuthenticated()
+        if kwargs.has_key("http") and kwargs["http"] == "unsecure":
+            options.transport = HttpAuthenticated()
+        else:
+            options.transport = HttpsAuthenticated()
         self.options = options
         options.cache = ObjectCache(days=1)
         self.set_options(**kwargs)
diff --git a/suds/transport/http.py b/suds/transport/http.py
index 6d85b09..5e1556e 100644
--- a/suds/transport/http.py
+++ b/suds/transport/http.py
@@ -58,6 +58,8 @@ class HttpTransport(Transport):
             url = request.url
             log.debug('opening (%s)', url)
             u2request = u2.Request(url)
+            for k, v in request.headers.iteritems():
+                u2request.add_header(k, v)
             self.proxy = self.options.proxy
             return self.u2open(u2request)
         except u2.HTTPError, e:



Cheers,
nicolas




This message and any attachments (the "message") is
intended solely for the addressees and is confidential. 
If you receive this message in error, please delete it and 
immediately notify the sender. Any use not in accord with 
its purpose, any dissemination or disclosure, either whole 
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message. 
BNP PARIBAS (and its subsidiaries) shall (will) not 
therefore be liable for the message if modified. 
Do not print this message unless it is necessary,
consider the environment.

                ---------------------------------------------

Ce message et toutes les pieces jointes (ci-apres le 
"message") sont etablis a l'intention exclusive de ses 
destinataires et sont confidentiels. Si vous recevez ce 
message par erreur, merci de le detruire et d'en avertir 
immediatement l'expediteur. Toute utilisation de ce 
message non conforme a sa destination, toute diffusion 
ou toute publication, totale ou partielle, est interdite, sauf 
autorisation expresse. L'internet ne permettant pas 
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce 
message, dans l'hypothese ou il aurait ete modifie.
N'imprimez ce message que si necessaire,
pensez a l'environnement.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/suds/attachments/20100713/09a6f6f8/attachment-0001.html 


More information about the suds mailing list