Skip to content
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

Cookies are not set properly after a redirect follow #696

Open
ondrejpialek opened this issue Apr 12, 2020 · 0 comments
Open

Cookies are not set properly after a redirect follow #696

ondrejpialek opened this issue Apr 12, 2020 · 0 comments

Comments

@ondrejpialek
Copy link

ondrejpialek commented Apr 12, 2020

Test request:

curl --location --request POST 'https://www.sainsburys.co.uk/shop/ShoppingListDisplay' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'shoppingList=RICE' \
--data-urlencode 'action=findProducts' \
--data-urlencode 'langId=44' \
--data-urlencode 'storeId=10151' \
--data-urlencode 'catalogueId=10241'

Expected result: HTTP 200 after 1 redirect.
Actual result: HTTP 403 ERROR after 1 redirect.

After running the HTTParty requests through Fiddler I discovered it is sending maligned cookies. First call that responds with a redirect sets the following cookies:

image

HTTParty follows the redirect and issues a GET request with the following cookies though:

image

For comparison, the same request executed via Postman results in the following set of cookies:

image

Seems like something goes wrong when the cookies are parsed from the first response. There is another issue open that talks about cookie parsing, perhaps it is time to look at these. I would have submitted a PR but this is my third week learning Ruby and Rails so you really wouldn't want to see my code! :)

NB: Should you also drop the Content-Type header when you follow a redirect using GET after an initial POST request?

Great library otherwise, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant