JETTY-1527 handle requests with URIs like http://host (ie no / )

This commit is contained in:
Greg Wilkins 2012-08-02 19:03:40 +10:00
parent 4d889de159
commit c998abc8bc
2 changed files with 19 additions and 1 deletions

View File

@ -439,7 +439,12 @@ public abstract class AbstractHttpConnection extends AbstractConnection
_uri.getPort();
info=URIUtil.canonicalPath(_uri.getDecodedPath());
if (info==null && !_request.getMethod().equals(HttpMethods.CONNECT))
throw new HttpException(400);
{
if (_uri.getScheme()!=null && _uri.getHost()!=null)
info="/";
else
throw new HttpException(400);
}
_request.setPathInfo(info);
if (_out!=null)

View File

@ -110,6 +110,19 @@ public class HttpConnectionTest
System.err.println(response);
}
}
@Test
public void testNoPath() throws Exception
{
String response=connector.getResponses("GET http://localhost:80 HTTP/1.1\n"+
"Host: localhost:80\n"+
"\n");
int offset=0;
offset = checkContains(response,offset,"HTTP/1.1 200");
checkContains(response,offset,"pathInfo=/");
}
@Test
public void testEmpty() throws Exception