h91d7 / python-ntlm

Automatically exported from code.google.com/p/python-ntlm
0 stars 0 forks source link

response object returned from retry_using_http_NTLM_auth does not have all the expected attributes #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm using python-ntlm with python-suds as shown on this blog post:

http://cbess.blogspot.com/2009/01/python-suds-with-windows-
authentication.html

When I do that however, as soon as the SUDS code tries to read cookies 
from the request, I get an error saying that the request has no 'info' 
attribute. Comparing the source to the urllib2.AbstractHTTPHandler.do_open 
code, it looks like the retry_using_http_NTLM_auth needs to be augmented a 
bit to return the same types of responses as other urllib2 handlers.

I've modified my copy of transport.py as follows and it seems to work well:

            try:
                h.request(req.get_method(), req.get_selector(), req.data, 
headers)
                # none of the configured handlers are triggered, for 
example redirect-responses are not handled!
                r = h.getresponse()

                # copied from urllib2.AbstractHTTPHandler.do_open
                r.recv = r.read
                fp = socket._fileobject(r, close=True)

                from urllib import addinfourl
                resp = addinfourl(fp, r.msg, req.get_full_url())
                resp.code = r.status
                resp.msg = r.reason
                return resp

Please let me know if there is anything else I should include in the bug 
report.

Thanks! Michael

Original issue reported on code.google.com by doo...@gmail.com on 21 Jan 2009 at 3:40

GoogleCodeExporter commented 8 years ago
This should be fixed in changeset 8 (r8)
Maybe you can verify the fix?

Original comment by Matthijs.Mullender on 29 Jan 2009 at 8:44

GoogleCodeExporter commented 8 years ago
Hi, that looks like it's worked. Thanks!

Also, I've noticed that URLError is not imported anywhere. I think you
need to add:

from urllib2 import URLError

Original comment by doo...@gmail.com on 6 Feb 2009 at 11:41