Skip to content

Removing body on GET requests #1130

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

Closed
wants to merge 1 commit into from
Closed

Removing body on GET requests #1130

wants to merge 1 commit into from

Conversation

spfink
Copy link
Contributor

@spfink spfink commented Mar 13, 2019

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.

@dagnir
Copy link
Contributor

dagnir commented Mar 13, 2019

This is tangential, but when we begin to support generating clients for API Gateway, this strategy will mean we don't support GET w/ bodies for those API's as well. This is true for v1 today so that's fine, but I just wanted to point that out to make sure we're okay with for v2 as well.

@@ -97,6 +97,14 @@ private Integer standardizePort(Integer port) {
return port;
}

private ContentStreamProvider standardizeBody(ContentStreamProvider contentStreamProvider) {
if (httpMethod.equals(SdkHttpMethod.GET)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also apply to DELETE and HEAD?

@@ -97,6 +97,14 @@ private Integer standardizePort(Integer port) {
return port;
}

private ContentStreamProvider standardizeBody(ContentStreamProvider contentStreamProvider) {
if (httpMethod.equals(SdkHttpMethod.GET)) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we warn or throw an exception if there was some body that got ignored because of the method?

@millems
Copy link
Contributor

millems commented Mar 25, 2019

Does this break any existing APIs?

@millems
Copy link
Contributor

millems commented Mar 25, 2019

Changelog?

@spfink
Copy link
Contributor Author

spfink commented Apr 3, 2019

Closing in favor of #1187

@spfink spfink closed this Apr 3, 2019
@spfink spfink deleted the finks/no-body-gets branch March 17, 2020 23:41
aws-sdk-java-automation added a commit that referenced this pull request Dec 30, 2020
…015318c69

Pull request: release <- staging/e3a71fc1-37ea-4121-af35-a6c015318c69
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.

3 participants