New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http_error_302() crashes with 'HTTP/1.1 400 Bad Request #41628
Comments
I was able to get to a website by using both IE and hh = urllib2.HTTPHandler()
hh.set_http_debuglevel(1)
opener = urllib2.build_opener
(hh,urllib2.HTTPCookieProcessor(self.cj)) The printed debug messages show that this crash reply: 'HTTP/1.1 302 Moved Temporarily\r\n' To fix this, I first tried to encode the redirected location A temporary solution that works is to replace any space def http_error_302(self, req, fp, code, msg, headers):
# Some servers (incorrectly) return multiple
Location headers
# (so probably same goes for URI). Use first
header.
if 'location' in headers:
newurl = headers.getheaders('location')[0]
elif 'uri' in headers:
newurl = headers.getheaders('uri')[0]
else:
return
newurl=newurl.replace(' ','%20') # <<< TEMP FIX -
inserting this line temporarily fixes this problem
newurl = urlparse.urljoin(req.get_full_url(), newurl)
<--- remainder of this function --> Thanks! |
Logged In: YES When the server sends the 302 response with 'Location: I believe based on reading rfc2396 that a URL that contains |
Logged In: YES Sure, but if Firefox and IE do it, probably we should do the I think cookielib.escape_path(), or something similar |
As always with urllib, the fix is trivial but adding a test is hard. |
Appears to be the same as bpo-918368 |
This bug refers to urllib2. bpo-918368 refers to urllib. It's the |
fixed in revision 43132 ( smaller 'r' for the roundup to auto-hyperlink). :) |
Sorry, I meant fixed in revision 72351. |
Commit in Git: commit 690ce9b
|
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: