Removing body on GET requests #1130
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is intended for discussion on #1078 and more generally the issue of bodies on GET requests. Both our Apache client and our URL connection client don't support GET requests with bodies.
Apache will simply silently drop the body. We can easily fix this.
The URL connection client will automatically switch any request with a body to a POST. It would not be easy to fix this without significantly forking.
Need to look into Netty.
Even without looking into Netty, the problem is clear. While GETs with bodies arent strictly disallowed, our clients don't support it by default. We probably could support it in all of our clients but this means specific code in each HTTP client. We can't support GETs with bodies generically for all clients.
This PR simply modifies the DefaultSdkHttpRequest to drop (silently) any body on a GET request. This is one option that allows us to make an easy change that would apply to all clients and any client that gets plugged in.
We could move this logic to the async and sync code paths rather than modifying the request pojo. It would likely allow us to log a little better.
We might be able to add support for this on a per client basis. Even if we could in all 3 of our clients, its not something people expect and since we are pluggable, its an edge case developers won't be aware of.