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

Clear body when redirecting to a GET #783

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

rhett-inbox
Copy link
Contributor

@rhett-inbox rhett-inbox commented May 2, 2023

Problem: Ran into a web application firewall that was blocking requests because the originating POST body was retained and transmitted upon redirection.

Solution: When redirecting, clear the body if the subsequent request is a GET

Note: Also extracted a method to keep the handle_response method more concise and cohesive IMHO

… getting lengthy. introduce logic to clear the body when redirecting to a GET
@jnunemaker
Copy link
Owner

Hi! Sorry I missed this. Is this what curl and other things do? Or is it a standard somewhere? I never know what to do in situations like this since I'm not sure if that is what everyone would want it to do or if it should be an option. Any insight would help.

@rhett-inbox
Copy link
Contributor Author

rhett-inbox commented Sep 13, 2023

Hi! Sorry I missed this. Is this what curl and other things do? Or is it a standard somewhere? I never know what to do in situations like this since I'm not sure if that is what everyone would want it to do or if it should be an option. Any insight would help.

hey @jnunemaker , no prob. Yes I believe it is a de facto standard. Here's one page that describes the behavior which is much easier to digest. I think the fact that the AWS infra was blocking the requests is additional evidence. And then when I was troubleshooting I wasn't able to repro in Postman because it was dropping the body too.

Edit: See also https://www.rfc-editor.org/rfc/rfc9110#section-9.3.1-6

I hope that mix of empirical and "canonical" info helps. I sympathize with the quandry, but I do think that this is the right choice for gem.

Happy to explore the convo further.

@chiraggshah
Copy link

chiraggshah commented Jan 30, 2024

@jnunemaker : cURL and Postman do the same.

@captn3m0
Copy link

captn3m0 commented Mar 7, 2024

Facing this at captn3m0/outliner#9 (CloudFront WAF by default blocks GET requests with a body). +1 to merging this, as current behaviour goes against both existing-usage and spec.

@jnunemaker jnunemaker merged commit cdae411 into jnunemaker:master Mar 11, 2024
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

Successfully merging this pull request may close these issues.

5 participants