406861 Fixed IPv6 redirect

This commit is contained in:
Greg Wilkins 2013-04-30 16:00:17 +10:00
parent e781393258
commit 4e62b953e1
1 changed files with 8 additions and 9 deletions

View File

@ -62,6 +62,7 @@ import org.eclipse.jetty.http.HttpCookie;
import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.HttpVersion;
@ -1067,19 +1068,17 @@ public class Request implements HttpServletRequest
{ {
StringBuilder url = new StringBuilder(48); StringBuilder url = new StringBuilder(48);
String scheme = getScheme(); String scheme = getScheme();
String server=getServerName();
int port = getServerPort(); int port = getServerPort();
url.append(scheme); if (server.indexOf(':')>=0)
url.append("://"); url.append(scheme).append("://").append('[').append(server).append(']');
if (getServerName().contains(":"))
url.append('[').append(getServerName()).append(']');
else else
url.append(getServerName()); url.append(scheme).append("://").append(getServerName());
if (port > 0 && ((scheme.equalsIgnoreCase("http") && port != 80) || (scheme.equalsIgnoreCase("https") && port != 443))) if (port > 0 && ((HttpScheme.HTTP.is(scheme) && port != 80) || (HttpScheme.HTTPS.is(scheme) && port != 443)))
{ {
url.append(':'); url.append(':').append(port);
url.append(port);
} }
return url; return url;
} }