python-ntlm icon indicating copy to clipboard operation
python-ntlm copied to clipboard

Ensure HTTP status results are handled tranparently, as usual in urllib2

Open GoogleCodeExporter opened this issue 9 years ago • 3 comments

What steps will reproduce the problem?
1. Try to retrieve a ntlm secured url that redirects to a second url
2. Currently only the first response to the first url is retrieved
3. The response then needs to be processed to locate the second url

What is the expected output? What do you see instead?
I expect to see the reponse from the second url

Original issue reported on code.google.com by Matthijs.Mullender on 10 Dec 2008 at 9:03

GoogleCodeExporter avatar Apr 07 '15 17:04 GoogleCodeExporter

Original comment by Matthijs.Mullender on 10 Dec 2008 at 9:03

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

GoogleCodeExporter avatar Apr 07 '15 17:04 GoogleCodeExporter

I created a python 2.6 modification of your library to fix this a while ago (I 
was 
working on a site that heavily used redirects). Attached is a diff of my 
changes that is 
intended to solve this issue.

I created two methods to replace your single NTLM authentication method. 
Control is 
transparently handed back to the urllib2 opener between method calls, allowing 
it to 
handle error codes such as 302 redirects.

To keep the connection alive I've lovingly stolen the HTTP handler from the 
urlgrabber library (http://linux.duke.edu/urlgrabber/).

Some caveats:
- I don't copy the undirected headers between requests like you do in your 
original 
library -- I couldn't see a reason to do so.
- I don't add a "Connection: close" header to the final request during NTLM 
communication. It's unneeded as the urlgrabber HTTP handler allows us to keep 
the 
connection open between requests, avoiding unnecessary extra authentication.
- I haven't made a python 3.0 version.
- This hasn't been tested for six months and subsequent modification has 
occurred, 
so it may not work right away. I hope that the diff can at least suggest a 
solution to 
this issue.

Original comment by [email protected] on 3 Feb 2010 at 1:43

Attachments:

GoogleCodeExporter avatar Apr 07 '15 17:04 GoogleCodeExporter

+1. This library just helped me authenticate against a site that I was unable to with other methods, but now I'm running into an issue because this library doesn't support redirects. It would be extremely helpful.

mrodrig avatar May 12 '15 12:05 mrodrig