Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2012-08-02 09:03:40 +0000
committerGreg Wilkins2012-08-02 09:03:40 +0000
commitc998abc8bcb248bbf9535aa48a9f74ba46fe0099 (patch)
tree22a3bd18961fa0755c4c188046650456a3968429
parent4d889de159dbda6b00c162fd70cc7ad7eaf68c6f (diff)
downloadorg.eclipse.jetty.project-c998abc8bcb248bbf9535aa48a9f74ba46fe0099.tar.gz
org.eclipse.jetty.project-c998abc8bcb248bbf9535aa48a9f74ba46fe0099.tar.xz
org.eclipse.jetty.project-c998abc8bcb248bbf9535aa48a9f74ba46fe0099.zip
JETTY-1527 handle requests with URIs like http://host (ie no / )
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java7
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java13
2 files changed, 19 insertions, 1 deletions
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java
index e1aeefef13..e4acf78ed2 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java
@@ -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)
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java
index 1e258f33a9..ef6b5ae432 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java
@@ -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

Back to the top