GrantU
GrantU

Reputation: 6555

httplib 303 See Other responce

I'm using httplib to make a post to a server. I'm getting back a 303 See Other. How do I see what the redirect message is '303 See Other' does not really help.

Thanks

conn1 = httplib.HTTPSConnection(url, 443, timeout=30)
            headers = {"Content-type": "application/text",
                   "Accept": "2"}

conn1.set_debuglevel(1)
conn1.request("POST", '', body.encode('utf8'), headers)
response = conn1.getresponse()
print response.status, response.reason

Upvotes: 1

Views: 162

Answers (1)

robertklep
robertklep

Reputation: 203514

The Location header will hold the URL that you are being redirected to:

print response.getheader('location')

If you want to see the actual page that was sent with the 303 (if there was one), read the response object as usual:

contents = response.read()

Upvotes: 2

Related Questions