411844 - ArrayIndexOutOfBoundsException on wild URL.
URLs like /path?= are now handled correctly.
This commit is contained in:
parent
8f190476b7
commit
0aa2a5b6bb
|
@ -542,7 +542,13 @@ public class HttpRequest implements Request
|
|||
for (String nameValue : query.split("&"))
|
||||
{
|
||||
String[] parts = nameValue.split("=");
|
||||
param(parts[0], parts.length < 2 ? "" : urlDecode(parts[1]));
|
||||
if (parts.length > 0)
|
||||
{
|
||||
String name = parts[0];
|
||||
if (name.trim().length() == 0)
|
||||
continue;
|
||||
param(name, parts.length < 2 ? "" : urlDecode(parts[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,4 +246,70 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
|
|||
|
||||
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoParameterNameNoParameterValue() throws Exception
|
||||
{
|
||||
final String path = "/path";
|
||||
final String query = "="; // Bogus query
|
||||
String pathQuery = path + "?" + query;
|
||||
start(new AbstractHandler()
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
{
|
||||
baseRequest.setHandled(true);
|
||||
Assert.assertEquals(path, request.getRequestURI());
|
||||
Assert.assertEquals(query, request.getQueryString());
|
||||
}
|
||||
});
|
||||
|
||||
Request request = client.newRequest("localhost", connector.getLocalPort())
|
||||
.scheme(scheme)
|
||||
.timeout(5, TimeUnit.SECONDS)
|
||||
.path(pathQuery);
|
||||
|
||||
Assert.assertEquals(path, request.getPath());
|
||||
Assert.assertEquals(query, request.getQuery());
|
||||
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
||||
Fields params = request.getParams();
|
||||
Assert.assertEquals(0, params.size());
|
||||
|
||||
ContentResponse response = request.send();
|
||||
|
||||
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoParameterNameWithParameterValue() throws Exception
|
||||
{
|
||||
final String path = "/path";
|
||||
final String query = "=1"; // Bogus query
|
||||
String pathQuery = path + "?" + query;
|
||||
start(new AbstractHandler()
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
{
|
||||
baseRequest.setHandled(true);
|
||||
Assert.assertEquals(path, request.getRequestURI());
|
||||
Assert.assertEquals(query, request.getQueryString());
|
||||
}
|
||||
});
|
||||
|
||||
Request request = client.newRequest("localhost", connector.getLocalPort())
|
||||
.scheme(scheme)
|
||||
.timeout(5, TimeUnit.SECONDS)
|
||||
.path(pathQuery);
|
||||
|
||||
Assert.assertEquals(path, request.getPath());
|
||||
Assert.assertEquals(query, request.getQuery());
|
||||
Assert.assertTrue(request.getURI().toString().endsWith(pathQuery));
|
||||
Fields params = request.getParams();
|
||||
Assert.assertEquals(0, params.size());
|
||||
|
||||
ContentResponse response = request.send();
|
||||
|
||||
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue