requests return empty list for a redirected URL

350 Views Asked by At

I am working with Python requests module. I provide an initial URL with redirects set to true.

resp = requests.request('GET', args.url, allow_redirects=True) 

Two redirects occur from the base URL which I capture using request history redirects = resp.history

The problem is for the second redirect request I cannot seem to find any cookies that are being set in the response headers (request.cookies returns empty list), but on inspecting in chrome I can clearly see cookies being set.

In Chrome:

Connection:keep-alive
Content-Length:0
Date:Tue, 18 Mar 2014 16:21:03 GMT
Expires:Thu, 01 Jan 1970 00:00:00 GMT
Location:http://tapestry.tapad.com/tapestry/1?ta_partner_id=937&ta_partner_did=777715362849735694&ta_format=gif
P3P:CP="NOI CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT"
Server:nginx/1.5.3
Set-Cookie:s19=1392755056185;Path=/;Domain=.rfihub.com;Expires=Sat, 03-Sep-2016 16:21:03   GMT
Set-Cookie:s3=1392755056185;Path=/;Domain=.rfihub.com;Expires=Sat, 03-Sep-2016 16:21:03 GMT
Set-Cookie:s11=1392755056185;Path=/;Domain=.rfihub.com;Expires=Sat, 03-Sep-2016 16:21:03 GMT
Set-Cookie:s9=1392755056185;Path=/;Domain=.rfihub.com;Expires=Sat, 03-Sep-2016 16:21:03 GMT
Set-Cookie:a=c777715362849735694;Path=/;Domain=.rfihub.com;Expires=Sat, 03-Sep-2016 16:21:03 GMT
Set-Cookie:s7=1393531849066;Path=/;Domain=.rfihub.com;Expires=Sat, 03-Sep-2016 16:21:03 GMT
Set-Cookie:s20=1392836060006;Path=/;Domain=.rfihub.com;Expires=Sat, 03-Sep-2016 16:21:03 GMT
Set-Cookie:s1=1392755056867;Path=/;Domain=.rfihub.com;Expires=Sat, 03-Sep-2016 16:21:03 GMT
Set-  Cookie:u=aACKXm6sQ==AIwv5YJg==AAABRNX_BL0=AIXgx0Yg==AAABRJlbvbg=;Path=/;Domain=.rfihub.com;Expires=Sat, 03-Sep-2016 16:21:03 GMT

While if I do a curl on the URL or handle it using python requests module, I don't see any of these cookies being set.

This is the redirected URL that is causing confusion:

 http://tapestry.tapad.com/tapestry/1?ta_partner_id=937&ta_partner_did=674976994738410472&ta_format=gif

Any help on this will be appreciated.

Thanks!

0

There are 0 best solutions below