aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Kellum2011-09-22 03:02:19 (EDT)
committerJesse McConnell2011-09-28 11:21:29 (EDT)
commitd37f2ca10c6bb17d237fce75a755ad73f35844ae (patch)
treeae083386141421c04d41cad9e71b5c3f58dafd4c
parent65e7d65442e027ce4046b09bdc914bb338513603 (diff)
downloadorg.eclipse.jetty.project-d37f2ca10c6bb17d237fce75a755ad73f35844ae.zip
org.eclipse.jetty.project-d37f2ca10c6bb17d237fce75a755ad73f35844ae.tar.gz
org.eclipse.jetty.project-d37f2ca10c6bb17d237fce75a755ad73f35844ae.tar.bz2
JETTY-1420 Set Host header for new request in RedirectListener
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java b/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java
index b46d2bc..cb06692 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/RedirectListener.java
@@ -115,8 +115,9 @@ public class RedirectListener extends HttpEventListenerWrapper
_exchange.setRequestURI(_location);
// destination may have changed
- HttpDestination destination=_destination.getHttpClient().getDestination(_exchange.getAddress(),HttpSchemes.HTTPS.equals(String.valueOf(_exchange.getScheme())));
-
+ boolean isHttps = HttpSchemes.HTTPS.equals(String.valueOf(_exchange.getScheme()));
+ HttpDestination destination=_destination.getHttpClient().getDestination(_exchange.getAddress(),isHttps);
+
if (_destination==destination)
_destination.resend(_exchange);
else
@@ -129,6 +130,19 @@ public class RedirectListener extends HttpEventListenerWrapper
_exchange.getEventListener().onRetry();
_exchange.reset();
_exchange.setEventListener(listener);
+
+ // Set the new Host header
+ Address adr = _exchange.getAddress();
+ int port = adr.getPort();
+ StringBuilder hh = new StringBuilder( 64 );
+ hh.append( adr.getHost() );
+ if( !( ( port == 80 && !isHttps ) ||
+ ( port == 443 && isHttps ) ) ) {
+ hh.append( ':' );
+ hh.append( port );
+ }
+ _exchange.setRequestHeader( HttpHeaders.HOST, hh.toString() );
+
destination.send(_exchange);
}