Merged branch 'master' into 'jetty-9.1'.
This commit is contained in:
commit
3b7322f53b
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class DefaultUserIdentity implements UserIdentity
|
|||
}
|
||||
|
||||
public boolean isUserInRole(String role, Scope scope)
|
||||
{
|
||||
{
|
||||
//Servlet Spec 3.1, pg 125
|
||||
if ("*".equals(role))
|
||||
return false;
|
||||
|
|
|
@ -75,7 +75,7 @@ public class RoleAnnotationTest extends HttpServlet
|
|||
result = request.isUserInRole("manager");
|
||||
out.println("<br/><b>Result: isUserInRole(\"manager\")="+result+":"+ (result?" <span class=\"pass\">PASS":" <span class=\"fail\">FAIL")+"</span></b>");
|
||||
result = request.isUserInRole("user");
|
||||
out.println("<br/><b>Result: isUserInRole(\"user\")="+result+":"+ (result==false?" <span class=\"pass\">PASS":" <span class=\"fail\">FAIL")+"</span></b>");
|
||||
out.println("<br/><b>Result: isUserInRole(\"user\")="+result+":"+ (result?" <span class=\"pass\">PASS":" <span class=\"fail\">FAIL")+"</span></b>");
|
||||
String context = _config.getServletContext().getContextPath();
|
||||
if (!context.endsWith("/"))
|
||||
context += "/";
|
||||
|
|
Loading…
Reference in New Issue