aws/aws-sdk-java — pull request #234 by ankon (2014-06-20 18:08:20+00:00)
Title: Reset the request content in retry cases before wrapping and buffering it

Content without known length (something that happens with requests for #setBucketLoggingConfiguration() for example)
will get wrapped and buffered, before it eventually ends up as "entity". Marking/Resetting the content stream
returned by BufferedHttpEntity is pretty pointless, as that is *recreated* on every call to #getContent(). At the same
time when the BufferedHttpEntity is created the second time (inside #createHttpRequest()), the underlying stream is already at its end,
so the buffering produces an *empty* buffer/entity.

This should (see below) fix cases where an S3 request with such an entity hits a 307 redirect.

----
Note that this issue leads to errors in perfectly valid requests, caused by something not controllable by the user (it seems the 307 redirects happen once in a while, without any reproducibility).

I can provide a wire dump of the case where I got a redirect from https://BUCKET.s3.amazonaws.com/?logging to https://BUCKET.s3-eu-west-1.amazonaws.com/?logging if you need it. The error I received was a (in hindsight) obvious "MalformedXML", because there was no XML in the second request at all.

Also note that when the redirect is executed the _original_ Host header is used, which smells suspicious to me. Currently I cannot reproduce the redirect, so cannot confirm whether this change is complete.