hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1518298 - /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
Date Wed, 28 Aug 2013 17:49:47 GMT
Author: olegk
Date: Wed Aug 28 17:49:46 2013
New Revision: 1518298

URL: http://svn.apache.org/r1518298
Log:
HTTPCLIENT-1393: original request headers do not get copied over in case of multiple redirects

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java?rev=1518298&r1=1518297&r2=1518298&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
Wed Aug 28 17:49:46 2013
@@ -116,12 +116,16 @@ public class RedirectExec implements Cli
                     }
                     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();



Mime
View raw message