Added HttpScheme.asString().
This commit is contained in:
parent
817b9ee5fa
commit
2b0cbac192
|
@ -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,22 +47,27 @@ public enum HttpScheme
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public ByteBuffer toBuffer()
|
||||
public ByteBuffer asByteBuffer()
|
||||
{
|
||||
return _buffer.asReadOnlyBuffer();
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean is(String s)
|
||||
{
|
||||
return _string.equalsIgnoreCase(s);
|
||||
return _string.equalsIgnoreCase(s);
|
||||
}
|
||||
|
||||
|
||||
public String asString()
|
||||
{
|
||||
return _string;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return _string;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class HttpURI
|
|||
{
|
||||
_charset = URIUtil.__CHARSET;
|
||||
}
|
||||
|
||||
|
||||
public HttpURI(Charset charset)
|
||||
{
|
||||
_charset = charset;
|
||||
|
@ -118,7 +118,7 @@ public class HttpURI
|
|||
parse2(b,0,b.length);
|
||||
_rawString=raw;
|
||||
}
|
||||
|
||||
|
||||
public void parseConnect(String raw)
|
||||
{
|
||||
byte[] b = StringUtil.getBytes(raw);
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -26,14 +25,14 @@ public abstract class AbstractHttpConnector extends AbstractConnector implements
|
|||
private String _forwardedProtoHeader = HttpHeader.X_FORWARDED_PROTO.toString();
|
||||
private String _forwardedCipherSuiteHeader;
|
||||
private String _forwardedSslSessionIdHeader;
|
||||
|
||||
|
||||
private int _requestHeaderSize;
|
||||
private int _requestBufferSize;
|
||||
private int _responseHeaderSize;
|
||||
private int _responseBufferSize;
|
||||
|
||||
|
||||
private ByteBufferPool _byteBufferPool;
|
||||
|
||||
|
||||
@Override
|
||||
public int getRequestHeaderSize()
|
||||
{
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +147,7 @@ public abstract class AbstractHttpConnector extends AbstractConnector implements
|
|||
}
|
||||
|
||||
if (forwardedFor != null)
|
||||
{
|
||||
{
|
||||
request.setRemoteAddr(new InetSocketAddress(forwardedFor,request.getRemotePort()));
|
||||
}
|
||||
|
||||
|
@ -455,6 +454,6 @@ public abstract class AbstractHttpConnector extends AbstractConnector implements
|
|||
{
|
||||
_forwardedSslSessionIdHeader = forwardedSslSessionId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue