Added HttpScheme.asString().

This commit is contained in:
Simone Bordet 2012-05-09 17:09:25 +02:00
parent 817b9ee5fa
commit 2b0cbac192
4 changed files with 24 additions and 21 deletions

View File

@ -33,7 +33,7 @@ public enum HttpScheme
static
{
for (HttpScheme version : HttpScheme.values())
CACHE.put(version.toString(),version);
CACHE.put(version.asString(),version);
}
private final String _string;
@ -47,7 +47,7 @@ public enum HttpScheme
}
/* ------------------------------------------------------------ */
public ByteBuffer toBuffer()
public ByteBuffer asByteBuffer()
{
return _buffer.asReadOnlyBuffer();
}
@ -58,6 +58,11 @@ public enum HttpScheme
return _string.equalsIgnoreCase(s);
}
public String asString()
{
return _string;
}
/* ------------------------------------------------------------ */
@Override
public String toString()

View File

@ -510,14 +510,14 @@ public class HttpURI
_raw[_scheme+1]=='t' &&
_raw[_scheme+2]=='t' &&
_raw[_scheme+3]=='p' )
return HttpScheme.HTTP.toString();
return HttpScheme.HTTP.asString();
if (l==6 &&
_raw[_scheme]=='h' &&
_raw[_scheme+1]=='t' &&
_raw[_scheme+2]=='t' &&
_raw[_scheme+3]=='p' &&
_raw[_scheme+4]=='s' )
return HttpScheme.HTTPS.toString();
return HttpScheme.HTTPS.asString();
return new String(_raw,_scheme,_authority-_scheme-1,_charset);
}

View File

@ -2,7 +2,6 @@ package org.eclipse.jetty.server;
import java.io.IOException;
import java.net.InetSocketAddress;
import javax.servlet.ServletRequest;
import org.eclipse.jetty.http.HttpFields;
@ -13,9 +12,9 @@ import org.eclipse.jetty.io.ByteBufferPool;
public abstract class AbstractHttpConnector extends AbstractConnector implements HttpConnector
{
private String _integralScheme = HttpScheme.HTTPS.toString();
private String _integralScheme = HttpScheme.HTTPS.asString();
private int _integralPort = 0;
private String _confidentialScheme = HttpScheme.HTTPS.toString();
private String _confidentialScheme = HttpScheme.HTTPS.asString();
private int _confidentialPort = 0;
private boolean _forwarded;
private String _hostHeader;
@ -115,7 +114,7 @@ public abstract class AbstractHttpConnector extends AbstractConnector implements
if(ssl_session_id!=null)
{
request.setAttribute("javax.servlet.request.ssl_session_id", ssl_session_id);
request.setScheme(HttpScheme.HTTPS.toString());
request.setScheme(HttpScheme.HTTPS.asString());
}
}

View File

@ -18,7 +18,6 @@ import java.io.PrintWriter;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
@ -179,7 +178,7 @@ public class Response implements HttpServletResponse
path = (path == null?"":path);
int port=uri.getPort();
if (port<0)
port = HttpScheme.HTTPS.toString().equalsIgnoreCase(uri.getScheme())?443:80;
port = HttpScheme.HTTPS.asString().equalsIgnoreCase(uri.getScheme())?443:80;
if (!request.getServerName().equalsIgnoreCase(uri.getHost()) ||
request.getServerPort()!=port ||
!path.startsWith(request.getContextPath())) //TODO the root context path is "", with which every non null string starts