[FROM SESSION-FUTURES] Multiple Redirects

https://github.com/ross/requests-futures/issues/6

The above link has the issue in it.


I see no issue in requests proper described there. It looks like you're using requests-futures incorrectly unless there are details you didn't update after trying to get the response from the futures object.


I do not think I am doing anything incorrectly with requests-futures. I really just can't conceptualize redirecting from page2 to page3 to page5 considering page3 is a temp page. The way to do this (according to ross) is through requests.


The expected behaviour is as follows:

You send a POST request to `/index.htm?pageNumber=2`. The server responds with a message that looks like this:

```
HTTP/1.1 302 Found
Location: /index.htm?pageNumber=3
```

When Requests sees the 302 it'll look for the `Location` header, and then kick off a new request (and will turn the verb into GET) to the `/index.htm?pageNumber=3` URL. The server will respond again:

```
HTTP/1.1 302 Found
Location: /index.htm?pageNumber=5
```

Requests will again follow the redirect, and will finally get a positive response:

```
HTTP/1.1 200 OK
...snip...
```

To confirm that this happened, please show us what `r.history` and `r.url` contain when you've finished the request.


`r.history` and `r.url` output (of which the URL is a combination of the pageNumber=2 URL and my payload):

[]
https://purchases.moneymappress.com/load1withcrosssell/ECHNN400/index.htm?pageNumber=2&formComponentsMap%5B%27order%27%5D.addressLine1=test&formComponentsMap%5B%27order%27%5D.shipToCity=&formComponentsMap%5B%27order%27%5D.addressLine2=test&_formComponentsMap%5B%27order%27%5D.hasSameShipToAddress=&formComponentsMap%5B%27order%27%5D.city=test&formComponentsMap%5B%27order%27%5D.faxNumber=&formComponentsMap%5B%27order%27%5D.shipToAddressLine1=&formComponentsMap%5B%27order%27%5D.shipToPostalCode=&formComponentsMap%5B%27order%27%5D.confirmShipToEmailAddress=&formComponentsMap%5B%27order%27%5D.shipToStateId=&formComponentsMap%5B%27order%27%5D.whichStateInput=dropDown&formComponentsMap%5B%27paymentOption%27%5D.creditCardSecurityCode=123&formComponentsMap%5B%27paymentOption%27%5D.effortPaymentOptionId=&formComponentsMap%5B%27order%27%5D.stateId=33&formComponentsMap%5B%27order%27%5D.shipToEmailAddress=&formComponentsMap%5B%27order%27%5D.emailAddress=akwebqa%2Bfuturessession0%40gmail.com&formComponentsMap%5B%27order%27%5D.password=123456&formComponentsMap%5B%27paymentOption%27%5D.creditCardTypeId=3&formComponentsMap%5B%27order%27%5D.shipToFirstName=&formComponentsMap%5B%27order%27%5D.wasPasswordFieldShown=true&formComponentsMap%5B%27order%27%5D.shipToCountryId=1&formComponentsMap%5B%27order%27%5D.shipToAddressLine2=&_formComponentsMap%5B%27order%27%5D.hasAgreedToBeContactedByAffiliates=&formComponentsMap%5B%27order%27%5D.phoneNumber=&formComponentsMap%5B%27paymentOption%27%5D.maskedCreditCardNumber=4444333322221111&formComponentsMap%5B%27offer%27%5D.choiceId=%27AGORA%27&formComponentsMap%5B%27order%27%5D.confirmEmailAddress=akwebqa%2Bfuturessession0%40gmail.com&formComponentsMap%5B%27order%27%5D.postalCode=21202&formComponentsMap%5B%27order%27%5D.whichShipToStateInput=dropDown&formComponentsMap%5B%27order%27%5D.shipToLastName=&formComponentsMap%5B%27offer%27%5D.pricingOptionId=%7B%0D%0A++++++++++++__onCountryChange__%3A+function%28countryId%2C+countryName&formComponentsMap%5B%27order%27%5D.lastName=test&formComponentsMap%5B%27paymentOption%27%5D.creditCardExpirationYear=2014&formComponentsMap%5B%27paymentOption%27%5D.creditCardExpirationMonth=3&formComponentsMap%5B%27order%27%5D.hasSameShipToAddress=true&formComponentsMap%5B%27order%27%5D.firstName=test&formComponentsMap%5B%27order%27%5D.countryId=1


Right, so you're not getting a 302 back. What's `r.status_code`?


200


Right, this is not Requests' fault. =)

The server is not providing any suggestion that you should be redirected. This will be because something about the request you're sending using Requests is different to the one you sent via Chrome. You need to compare the two. Are you familiar with Wireshark/tcpdump?


One more option is set up proxy and monitor the request and response.
On Aug 28, 2013 8:52 PM, "Cory Benfield" notifications@github.com wrote:

> Right, this is not Requests' fault. =)
> 
> The server is not providing any suggestion that you should be redirected.
> This will be because something about the request you're sending using
> Requests is different to the one you sent via Chrome. You need to compare
> the two. Are you familiar with Wireshark/tcpdump?
> 
> —
> Reply to this email directly or view it on GitHubhttps://github.com/kennethreitz/requests/issues/1557#issuecomment-23423137
> .


Would those options still work if the website I am trying to access is on a SSL protocol (I am not familiar with Wireshark/tcpdump)?


Ah, then it's harder. At this point a man-in-the-middle proxy is likely to be your best bet.


So I changed my post to post to pageNumber=5 instead of 2 and I am now getting a `r.history` of 302 but a `r.url` of https://purchases.moneymappress.com/load1withcrosssell/ECHNN400/index.htm?pageNumber=2


Yup, so that indicates that you're being redirected to pageNumber=2. You should sit back and attempt to work out how the URI scheme for this website works.


With the most recent discussion, I am certain this is not a bug in requests or how we handle redirects. That said, if you need further advice please post your questions to StackOverflow