297104 Improve handling of CONNECT method

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1498 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-04-12 17:03:27 +00:00
parent 37fecf26e5
commit ad7da40f1e
2 changed files with 13 additions and 14 deletions

View File

@ -574,7 +574,7 @@ public class HttpConnection implements Connection
{
_uri.getPort();
info=URIUtil.canonicalPath(_uri.getDecodedPath());
if (info==null)
if (info==null && !_request.getMethod().equals(HttpMethods.CONNECT))
throw new HttpException(400);
_request.setPathInfo(info);
@ -837,7 +837,7 @@ public class HttpConnection implements Connection
switch (HttpMethods.CACHE.getOrdinal(method))
{
case HttpMethods.CONNECT_ORDINAL:
_uri.parseConnect(uri.array(), uri.getIndex(), uri.length());
_uri.parseConnect(uri.array(), uri.getIndex(), uri.length());
break;
case HttpMethods.HEAD_ORDINAL:

View File

@ -758,11 +758,18 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
if (connector==null || !_connectors.contains(connector))
return false;
}
if (target.startsWith(_contextPath))
// Are we not the root context?
if (_contextPath.length()>1)
{
if (_contextPath.length()==target.length() && _contextPath.length()>1 &&!_allowNullPathInfo)
// reject requests that are not for us
if (!target.startsWith(_contextPath))
return false;
if (target.length()>_contextPath.length() && target.charAt(_contextPath.length())!='/')
return false;
// redirect null path infos
if (!_allowNullPathInfo && _contextPath.length()==target.length())
{
// context request must end with /
baseRequest.setHandled(true);
@ -773,14 +780,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
return false;
}
}
else
{
if (HttpMethods.CONNECT.equalsIgnoreCase(baseRequest.getMethod()) && "/".equals(_contextPath))
return true;
// Not for this context!
return false;
}
return true;
}