rlalfo / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

Post/redirect/GET idiom breaks due to leftover content #225

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-http-java-client (e.g. 1.15.0-rc)?

1.15.0-rc

Java environment (e.g. Java 6, Android 2.3, App Engine)?

App Engine development server, but should be environment-independent

Describe the problem.

When a server returns a 303 redirect, the client properly switches to GET 
method, but leaves the content from the original POST in the HttpRequest. This 
causes the subsequent GET to fail with "GET with non-zero content length is not 
supported".

How would you expect it to be fixed?

In HttpRequest.handleRedirect,

// on 303 change method to GET
if (statusCode == HttpStatusCodes.STATUS_CODE_SEE_OTHER) {
  setRequestMethod(HttpMethods.GET);
  // make sure content from POST does not pollute next GET
  setContent(null);
}

Original issue reported on code.google.com by rapro...@gmail.com on 24 May 2013 at 7:20

GoogleCodeExporter commented 9 years ago
Agreed.

Original comment by yan...@google.com on 15 Aug 2013 at 11:47

GoogleCodeExporter commented 9 years ago
Thanks for the report!
https://codereview.appspot.com/13094046/

Original comment by ngmic...@google.com on 21 Aug 2013 at 8:48

GoogleCodeExporter commented 9 years ago

Original comment by ngmic...@google.com on 23 Aug 2013 at 3:42