HTTPCLIENT-1393: original request headers do not get copied over in case of multiple redirects

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1518298 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2013-08-28 17:49:46 +00:00
parent c787841e42
commit d6216b4257
1 changed files with 9 additions and 5 deletions

View File

@ -116,12 +116,16 @@ public class RedirectExec implements ClientExecChain {
}
redirectCount++;
final HttpRequest redirect = this.redirectStrategy.getRedirect(currentRequest, response, context);
final HttpRequest original = currentRequest.getOriginal();
final HttpRequest redirect = this.redirectStrategy.getRedirect(
currentRequest, response, context);
if (!redirect.headerIterator().hasNext()) {
final HttpRequest original = request.getOriginal();
redirect.setHeaders(original.getAllHeaders());
}
currentRequest = HttpRequestWrapper.wrap(redirect);
currentRequest.setHeaders(original.getAllHeaders());
if (original instanceof HttpEntityEnclosingRequest) {
Proxies.enhanceEntity((HttpEntityEnclosingRequest) request);
if (currentRequest instanceof HttpEntityEnclosingRequest) {
Proxies.enhanceEntity((HttpEntityEnclosingRequest) currentRequest);
}
final URI uri = currentRequest.getURI();