Closed GoogleCodeExporter closed 9 years ago
A correction of formulation. When I set follow_redirects = False, I find after
visiting the 302 page, the cookie is set. So I guess when follow_redirects is
set to True, this cookie is auto discarded when visiting the page to redirect
to (i.e. the Location page). However, this might not be what the user wants,
because the cookies set by the 302 page may be useful in the Location page.
Original comment by cyker...@gmail.com
on 17 Jun 2011 at 4:18
httplib2 has no cookie handling yet.
Original comment by joe.gregorio@gmail.com
on 17 Jun 2011 at 5:39
Hi Joe,
I also have this problem, and have a simple work-around by adding one line
coding.
In httplib2.Http._request(), there is a part of redirection handling. So, I add
my code as below.
if response.has_key('location'):
location = response['location']
old_response = copy.deepcopy(response)
if not old_response.has_key('content-location'):
old_response['content-location'] = absolute_uri
redirect_method = method
if response.status in [302, 303]:
# Add by Deren
headers['Cookie'] = response['set-cookie']
redirect_method = "GET"
body = None
(response, content) = self.request(location, redirect_method, body=body, headers = headers, redirections = redirections - 1)
response.previous = old_response
Just for your reference!
Good luck,
Deren
Original comment by dere...@gmail.com
on 5 Nov 2013 at 8:02
Original issue reported on code.google.com by
cyker...@gmail.com
on 17 Jun 2011 at 3:50