Merge remote-tracking branch 'origin/jetty-9.4.x'

This commit is contained in:
Greg Wilkins 2017-06-06 12:27:52 +02:00
commit 10bb8c3605
23 changed files with 205 additions and 201 deletions

View File

@ -147,14 +147,14 @@ public class JaspiTest
@Test
public void testNoConstraint() throws Exception
{
String response = _connector.getResponses("GET /ctx/test HTTP/1.0\n\n");
String response = _connector.getResponse("GET /ctx/test HTTP/1.0\n\n");
assertThat(response,startsWith("HTTP/1.1 200 OK"));
}
@Test
public void testConstraintNoAuth() throws Exception
{
String response = _connector.getResponses("GET /ctx/jaspi/test HTTP/1.0\n\n");
String response = _connector.getResponse("GET /ctx/jaspi/test HTTP/1.0\n\n");
assertThat(response,startsWith("HTTP/1.1 401 Unauthorized"));
assertThat(response,Matchers.containsString("WWW-Authenticate: basic realm=\"TestRealm\""));
}
@ -162,7 +162,7 @@ public class JaspiTest
@Test
public void testConstraintWrongAuth() throws Exception
{
String response = _connector.getResponses("GET /ctx/jaspi/test HTTP/1.0\n"+
String response = _connector.getResponse("GET /ctx/jaspi/test HTTP/1.0\n"+
"Authorization: Basic " + B64Code.encode("user:wrong") + "\n\n");
assertThat(response,startsWith("HTTP/1.1 401 Unauthorized"));
assertThat(response,Matchers.containsString("WWW-Authenticate: basic realm=\"TestRealm\""));
@ -171,7 +171,7 @@ public class JaspiTest
@Test
public void testConstraintAuth() throws Exception
{
String response = _connector.getResponses("GET /ctx/jaspi/test HTTP/1.0\n"+
String response = _connector.getResponse("GET /ctx/jaspi/test HTTP/1.0\n"+
"Authorization: Basic " + B64Code.encode("user:password") + "\n\n");
assertThat(response,startsWith("HTTP/1.1 200 OK"));
}
@ -179,14 +179,14 @@ public class JaspiTest
@Test
public void testOtherNoAuth() throws Exception
{
String response = _connector.getResponses("GET /other/test HTTP/1.0\n\n");
String response = _connector.getResponse("GET /other/test HTTP/1.0\n\n");
assertThat(response,startsWith("HTTP/1.1 403 Forbidden"));
}
@Test
public void testOtherAuth() throws Exception
{
String response = _connector.getResponses("GET /other/test HTTP/1.0\n"+
String response = _connector.getResponse("GET /other/test HTTP/1.0\n"+
"X-Forwarded-User: user\n\n");
assertThat(response,startsWith("HTTP/1.1 200 OK"));
}

View File

@ -158,7 +158,7 @@ public class AliasedConstraintTest
request.append("Connection: close\r\n");
request.append("\r\n");
String response = connector.getResponses(request.toString());
String response = connector.getResponse(request.toString());
switch (expectedStatusCode)
{

View File

@ -130,15 +130,15 @@ public class DataConstraintsTest
_server.start();
String response;
response = _connector.getResponses("GET /ctx/some/thing HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/some/thing HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
response = _connector.getResponses("GET /ctx/integral/info HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/integral/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
Assert.assertThat(response, Matchers.containsString("Location: BWTP://"));
Assert.assertThat(response, Matchers.containsString(":9999"));
response = _connectorS.getResponses("GET /ctx/integral/info HTTP/1.0\r\n\r\n");
response = _connectorS.getResponse("GET /ctx/integral/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
}
@ -162,15 +162,15 @@ public class DataConstraintsTest
_server.start();
String response;
response = _connector.getResponses("GET /ctx/some/thing HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/some/thing HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
response = _connector.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
Assert.assertThat(response, Matchers.containsString("Location: BWTP://"));
Assert.assertThat(response, Matchers.containsString(":9999"));
response = _connectorS.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connectorS.getResponse("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
}
@ -194,10 +194,10 @@ public class DataConstraintsTest
String response;
response = _connector.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
response = _connectorS.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connectorS.getResponse("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
}
@ -222,16 +222,16 @@ public class DataConstraintsTest
String response;
response = _connector.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
response = _connectorS.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connectorS.getResponse("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
response = _connector.getResponses("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connector.getResponse("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
response = _connectorS.getResponses("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connectorS.getResponse("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
}
@ -256,16 +256,16 @@ public class DataConstraintsTest
String response;
response = _connector.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
response = _connectorS.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connectorS.getResponse("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
response = _connector.getResponses("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connector.getResponse("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
response = _connectorS.getResponses("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connectorS.getResponse("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
}
@ -295,25 +295,25 @@ public class DataConstraintsTest
String response;
response = _connector.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
response = _connectorS.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connectorS.getResponse("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
response = _connector.getResponses("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connector.getResponse("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
response = _connectorS.getResponses("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
response = _connectorS.getResponse("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 401 Unauthorized"));
response = _connector.getResponses("GET /ctx/confid/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
response = _connector.getResponse("GET /ctx/confid/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
response = _connector.getResponses("POST /ctx/confid/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
response = _connector.getResponse("POST /ctx/confid/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
response = _connectorS.getResponses("POST /ctx/confid/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
response = _connectorS.getResponse("POST /ctx/confid/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
}
@ -337,16 +337,16 @@ public class DataConstraintsTest
String response;
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
response = _connectorS.getResponse("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
response = _connector.getResponse("GET /ctx/restricted/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
response = _connectorS.getResponse("GET /ctx/restricted/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
}
@ -371,16 +371,16 @@ public class DataConstraintsTest
String response;
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
response = _connectorS.getResponse("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
response = _connector.getResponse("GET /ctx/restricted/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
response = _connectorS.getResponse("GET /ctx/restricted/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
}
@ -409,16 +409,16 @@ public class DataConstraintsTest
String response;
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 401 Unauthorized"));
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
response = _connectorS.getResponse("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 401 Unauthorized"));
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\n\n");
response = _connector.getResponse("GET /ctx/restricted/info HTTP/1.0\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\n\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\n\n");
response = _connectorS.getResponse("GET /ctx/restricted/info HTTP/1.0\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\n\n");
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
}

View File

@ -257,14 +257,14 @@ public class SpecExampleConstraintTest
//There are uncovered methods for GET/POST at url /*
//without deny-uncovered-http-methods they should be accessible
String response;
response = _connector.getResponses("GET /ctx/index.html HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/index.html HTTP/1.0\r\n\r\n");
assertThat(response,startsWith("HTTP/1.1 200 OK"));
//set deny-uncovered-http-methods true
_security.setDenyUncoveredHttpMethods(true);
//check they cannot be accessed
response = _connector.getResponses("GET /ctx/index.html HTTP/1.0\r\n\r\n");
response = _connector.getResponse("GET /ctx/index.html HTTP/1.0\r\n\r\n");
assertTrue(response.startsWith("HTTP/1.1 403 Forbidden"));
}
finally
@ -294,39 +294,39 @@ public class SpecExampleConstraintTest
*/
//a user in role HOMEOWNER is forbidden HEAD request
response = _connector.getResponses("HEAD /ctx/index.html HTTP/1.0\r\n\r\n");
response = _connector.getResponse("HEAD /ctx/index.html HTTP/1.0\r\n\r\n");
assertTrue(response.startsWith("HTTP/1.1 403 Forbidden"));
response = _connector.getResponses("HEAD /ctx/index.html HTTP/1.0\r\n" +
response = _connector.getResponse("HEAD /ctx/index.html HTTP/1.0\r\n" +
"Authorization: Basic " + B64Code.encode("harry:password") + "\r\n" +
"\r\n");
assertThat(response,startsWith("HTTP/1.1 403 Forbidden"));
response = _connector.getResponses("HEAD /ctx/acme/wholesale/index.html HTTP/1.0\r\n" +
response = _connector.getResponse("HEAD /ctx/acme/wholesale/index.html HTTP/1.0\r\n" +
"Authorization: Basic " + B64Code.encode("harry:password") + "\r\n" +
"\r\n");
assertThat(response,startsWith("HTTP/1.1 403 Forbidden"));
response = _connector.getResponses("HEAD /ctx/acme/retail/index.html HTTP/1.0\r\n" +
response = _connector.getResponse("HEAD /ctx/acme/retail/index.html HTTP/1.0\r\n" +
"Authorization: Basic " + B64Code.encode("harry:password") + "\r\n" +
"\r\n");
assertThat(response,startsWith("HTTP/1.1 403 Forbidden"));
//a user in role CONTRACTOR can do a GET
response = _connector.getResponses("GET /ctx/acme/wholesale/index.html HTTP/1.0\r\n" +
response = _connector.getResponse("GET /ctx/acme/wholesale/index.html HTTP/1.0\r\n" +
"Authorization: Basic " + B64Code.encode("chris:password") + "\r\n" +
"\r\n");
assertThat(response,startsWith("HTTP/1.1 200 OK"));
//a user in role CONTRACTOR can only do a post if confidential
response = _connector.getResponses("POST /ctx/acme/wholesale/index.html HTTP/1.0\r\n" +
response = _connector.getResponse("POST /ctx/acme/wholesale/index.html HTTP/1.0\r\n" +
"Authorization: Basic " + B64Code.encode("chris:password") + "\r\n" +
"\r\n");
assertThat(response,startsWith("HTTP/1.1 403 !"));
//a user in role HOMEOWNER can do a GET
response = _connector.getResponses("GET /ctx/acme/retail/index.html HTTP/1.0\r\n" +
response = _connector.getResponse("GET /ctx/acme/retail/index.html HTTP/1.0\r\n" +
"Authorization: Basic " + B64Code.encode("harry:password") + "\r\n" +
"\r\n");
assertThat(response,startsWith("HTTP/1.1 200 OK"));

View File

@ -151,9 +151,7 @@ public class CheckReverseProxyHeadersTest
try
{
server.start();
connector.getResponses("GET / HTTP/1.1\r\n" +"Connection: close\r\n" + headers + "\r\n\r\n",
1000,TimeUnit.SECONDS);
connector.getResponse("GET / HTTP/1.1\r\n" +"Connection: close\r\n" + headers + "\r\n\r\n");
Error error = validationHandler.getError();
if (error != null)

View File

@ -579,7 +579,7 @@ public class HttpOutputTest
_handler._byteBuffer = BufferUtil.allocateDirect(8192);
_handler._async = true;
String response = _connector.getResponses("GET / HTTP/1.0\nHost: localhost:80\n\n");
String response = _connector.getResponse("GET / HTTP/1.0\nHost: localhost:80\n\n");
assertThat(response, containsString("HTTP/1.1 200 OK"));
assertThat(response, Matchers.not(containsString("Content-Length")));
assertThat(response, endsWith(toUTF8String(big)));

View File

@ -79,7 +79,7 @@ public class LocalConnectorTest
}
});
_connector.getResponses("" +
_connector.getResponse("" +
"GET / HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Connection: close\r\n" +
@ -92,7 +92,7 @@ public class LocalConnectorTest
@Test
public void testOneGET() throws Exception
{
String response=_connector.getResponses("GET /R1 HTTP/1.0\r\n\r\n");
String response=_connector.getResponse("GET /R1 HTTP/1.0\r\n\r\n");
assertThat(response,containsString("HTTP/1.1 200 OK"));
assertThat(response,containsString("pathInfo=/R1"));
}
@ -301,14 +301,14 @@ public class LocalConnectorTest
@Test
public void testStopStart() throws Exception
{
String response=_connector.getResponses("GET /R1 HTTP/1.0\r\n\r\n");
String response=_connector.getResponse("GET /R1 HTTP/1.0\r\n\r\n");
assertThat(response,containsString("HTTP/1.1 200 OK"));
assertThat(response,containsString("pathInfo=/R1"));
_server.stop();
_server.start();
response=_connector.getResponses("GET /R2 HTTP/1.0\r\n\r\n");
response=_connector.getResponse("GET /R2 HTTP/1.0\r\n\r\n");
assertThat(response,containsString("HTTP/1.1 200 OK"));
assertThat(response,containsString("pathInfo=/R2"));
}
@ -316,12 +316,15 @@ public class LocalConnectorTest
@Test
public void testTwoGETs() throws Exception
{
String response=_connector.getResponses(
LocalEndPoint endp = _connector.connect();
endp.addInput(
"GET /R1 HTTP/1.1\r\n"+
"Host: localhost\r\n"+
"\r\n"+
"GET /R2 HTTP/1.0\r\n\r\n");
String response = endp.getResponse() + endp.getResponse();
assertThat(response,containsString("HTTP/1.1 200 OK"));
assertThat(response,containsString("pathInfo=/R1"));
@ -355,7 +358,8 @@ public class LocalConnectorTest
@Test
public void testManyGETs() throws Exception
{
String response=_connector.getResponses(
LocalEndPoint endp = _connector.connect();
endp.addInput(
"GET /R1 HTTP/1.1\r\n"+
"Host: localhost\r\n"+
"\r\n"+
@ -376,7 +380,10 @@ public class LocalConnectorTest
"Connection: close\r\n"+
"\r\n");
String r=response;
String r="";
for (String response=endp.getResponse();response!=null;response=endp.getResponse())
r+=response;
for (int i=1;i<=6;i++)
{

View File

@ -18,7 +18,6 @@
package org.eclipse.jetty.server;
import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.server.handler.ErrorHandler;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.hamcrest.Matchers;
@ -67,7 +66,7 @@ public class ProxyConnectionTest
@Test
public void testSimple() throws Exception
{
String response=_connector.getResponses("PROXY TCP 1.2.3.4 5.6.7.8 111 222\r\n"+
String response=_connector.getResponse("PROXY TCP 1.2.3.4 5.6.7.8 111 222\r\n"+
"GET /path HTTP/1.1\n"+
"Host: server:80\n"+
"Connection: close\n"+
@ -82,7 +81,7 @@ public class ProxyConnectionTest
@Test
public void testIPv6() throws Exception
{
String response=_connector.getResponses("PROXY UNKNOWN eeee:eeee:eeee:eeee:eeee:eeee:eeee:eeee ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 65535 65535\r\n"+
String response=_connector.getResponse("PROXY UNKNOWN eeee:eeee:eeee:eeee:eeee:eeee:eeee:eeee ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 65535 65535\r\n"+
"GET /path HTTP/1.1\n"+
"Host: server:80\n"+
"Connection: close\n"+
@ -97,43 +96,43 @@ public class ProxyConnectionTest
@Test
public void testTooLong() throws Exception
{
String response=_connector.getResponses("PROXY TOOLONG!!! eeee:eeee:eeee:eeee:0000:0000:0000:0000 ffff:ffff:ffff:ffff:0000:0000:0000:0000 65535 65535\r\n"+
String response=_connector.getResponse("PROXY TOOLONG!!! eeee:eeee:eeee:eeee:0000:0000:0000:0000 ffff:ffff:ffff:ffff:0000:0000:0000:0000 65535 65535\r\n"+
"GET /path HTTP/1.1\n"+
"Host: server:80\n"+
"Connection: close\n"+
"\n");
Assert.assertThat(response,Matchers.equalTo(""));
Assert.assertNull(response);
}
@Test
public void testNotComplete() throws Exception
{
_connector.setIdleTimeout(100);
String response=_connector.getResponses("PROXY TIMEOUT");
Assert.assertThat(response,Matchers.equalTo(""));
String response=_connector.getResponse("PROXY TIMEOUT");
Assert.assertNull(response);
}
@Test
public void testBadChar() throws Exception
{
String response=_connector.getResponses("PROXY\tTCP 1.2.3.4 5.6.7.8 111 222\r\n"+
String response=_connector.getResponse("PROXY\tTCP 1.2.3.4 5.6.7.8 111 222\r\n"+
"GET /path HTTP/1.1\n"+
"Host: server:80\n"+
"Connection: close\n"+
"\n");
Assert.assertThat(response,Matchers.equalTo(""));
Assert.assertNull(response);
}
@Test
public void testBadCRLF() throws Exception
{
String response=_connector.getResponses("PROXY TCP 1.2.3.4 5.6.7.8 111 222\r \n"+
String response=_connector.getResponse("PROXY TCP 1.2.3.4 5.6.7.8 111 222\r \n"+
"GET /path HTTP/1.1\n"+
"Host: server:80\n"+
"Connection: close\n"+
"\n");
Assert.assertThat(response,Matchers.equalTo(""));
Assert.assertNull(response);
}
@Test
@ -141,35 +140,35 @@ public class ProxyConnectionTest
{
try(StacklessLogging stackless = new StacklessLogging(ProxyConnectionFactory.class))
{
String response=_connector.getResponses("PROXY TCP 1.2.3.4 5.6.7.8 9999999999999 222\r\n"+
String response=_connector.getResponse("PROXY TCP 1.2.3.4 5.6.7.8 9999999999999 222\r\n"+
"GET /path HTTP/1.1\n"+
"Host: server:80\n"+
"Connection: close\n"+
"\n");
Assert.assertThat(response,Matchers.equalTo(""));
Assert.assertNull(response);
}
}
@Test
public void testMissingField() throws Exception
{
String response=_connector.getResponses("PROXY TCP 1.2.3.4 5.6.7.8 222\r\n"+
String response=_connector.getResponse("PROXY TCP 1.2.3.4 5.6.7.8 222\r\n"+
"GET /path HTTP/1.1\n"+
"Host: server:80\n"+
"Connection: close\n"+
"\n");
Assert.assertThat(response,Matchers.equalTo(""));
Assert.assertNull(response);
}
@Test
public void testHTTP() throws Exception
{
String response=_connector.getResponses(
String response=_connector.getResponse(
"GET /path HTTP/1.1\n"+
"Host: server:80\n"+
"Connection: close\n"+
"\n");
Assert.assertThat(response,Matchers.equalTo(""));
Assert.assertNull(response);
}
}

View File

@ -140,7 +140,7 @@ public class ContextHandlerCollectionTest
handlerF.reset();
String t = String.format("test %d %s@%s --> %s | %s%n",i,uri,host,connector.getName(),handler);
String response = connector.getResponses("GET "+uri+" HTTP/1.0\nHost: "+host+"\n\n");
String response = connector.getResponse("GET "+uri+" HTTP/1.0\nHost: "+host+"\n\n");
if (handler==null)
{
@ -301,32 +301,32 @@ public class ContextHandlerCollectionTest
server.setHandler(contexts);
server.start();
String response=connector.getResponses("GET / HTTP/1.0\r\n\r\n");
String response=connector.getResponse("GET / HTTP/1.0\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
assertThat(response, endsWith("root"));
assertThat(response, not(containsString("Wrapped: TRUE")));
response=connector.getResponses("GET /foobar/info HTTP/1.0\r\n\r\n");
response=connector.getResponse("GET /foobar/info HTTP/1.0\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
assertThat(response, endsWith("root"));
assertThat(response, not(containsString("Wrapped: TRUE")));
response=connector.getResponses("GET /left/info HTTP/1.0\r\n\r\n");
response=connector.getResponse("GET /left/info HTTP/1.0\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
assertThat(response, endsWith("left"));
assertThat(response, not(containsString("Wrapped: TRUE")));
response=connector.getResponses("GET /leftcentre/info HTTP/1.0\r\n\r\n");
response=connector.getResponse("GET /leftcentre/info HTTP/1.0\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
assertThat(response, endsWith("left of centre"));
assertThat(response, not(containsString("Wrapped: TRUE")));
response=connector.getResponses("GET /rightcentre/info HTTP/1.0\r\n\r\n");
response=connector.getResponse("GET /rightcentre/info HTTP/1.0\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
assertThat(response, endsWith("right of centre"));
assertThat(response, containsString("Wrapped: TRUE"));
response=connector.getResponses("GET /right/info HTTP/1.0\r\n\r\n");
response=connector.getResponse("GET /right/info HTTP/1.0\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
assertThat(response, endsWith("right"));
assertThat(response, containsString("Wrapped: TRUE"));
@ -362,32 +362,32 @@ public class ContextHandlerCollectionTest
server.setHandler(contexts);
server.start();
String response=connector.getResponses("GET / HTTP/1.0\r\n\r\n");
String response=connector.getResponse("GET / HTTP/1.0\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
assertThat(response, endsWith("root"));
assertThat(response, not(containsString("Wrapped: TRUE")));
response=connector.getResponses("GET /foobar/info HTTP/1.0\r\n\r\n");
response=connector.getResponse("GET /foobar/info HTTP/1.0\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
assertThat(response, endsWith("root"));
assertThat(response, not(containsString("Wrapped: TRUE")));
response=connector.getResponses("GET /left/info HTTP/1.0\r\n\r\n");
response=connector.getResponse("GET /left/info HTTP/1.0\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
assertThat(response, endsWith("left"));
assertThat(response, not(containsString("Wrapped: TRUE")));
response=connector.getResponses("GET /leftcentre/info HTTP/1.0\r\n\r\n");
response=connector.getResponse("GET /leftcentre/info HTTP/1.0\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
assertThat(response, endsWith("left of centre"));
assertThat(response, not(containsString("Wrapped: TRUE")));
response=connector.getResponses("GET /rightcentre/info HTTP/1.0\r\n\r\n");
response=connector.getResponse("GET /rightcentre/info HTTP/1.0\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
assertThat(response, endsWith("right of centre"));
assertThat(response, containsString("Wrapped: ASYNC"));
response=connector.getResponses("GET /right/info HTTP/1.0\r\n\r\n");
response=connector.getResponse("GET /right/info HTTP/1.0\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
assertThat(response, endsWith("right"));
assertThat(response, containsString("Wrapped: ASYNC"));

View File

@ -90,7 +90,7 @@ public class ContextHandlerTest
try
{
server.start();
connector.getResponses("GET / HTTP/1.0\n" + "Host: www.example.com.\n\n");
connector.getResponse("GET / HTTP/1.0\n" + "Host: www.example.com.\n\n");
Assert.assertTrue(handlerA.isHandled());
Assert.assertFalse(handlerB.isHandled());
@ -100,7 +100,7 @@ public class ContextHandlerTest
handlerB.reset();
handlerC.reset();
connector.getResponses("GET / HTTP/1.0\n" + "Host: www.example2.com\n\n");
connector.getResponse("GET / HTTP/1.0\n" + "Host: www.example2.com\n\n");
Assert.assertFalse(handlerA.isHandled());
Assert.assertTrue(handlerB.isHandled());
@ -147,7 +147,7 @@ public class ContextHandlerTest
server.start();
try
{
connector.getResponses("GET / HTTP/1.0\n" + "Host: www.example.com.\n\n");
connector.getResponse("GET / HTTP/1.0\n" + "Host: www.example.com.\n\n");
Assert.assertTrue(handlerA.isHandled());
Assert.assertFalse(handlerB.isHandled());
Assert.assertFalse(handlerC.isHandled());
@ -155,7 +155,7 @@ public class ContextHandlerTest
handlerB.reset();
handlerC.reset();
connector.getResponses("GET / HTTP/1.0\n" + "Host: localhost\n\n");
connector.getResponse("GET / HTTP/1.0\n" + "Host: localhost\n\n");
Assert.assertFalse(handlerA.isHandled());
Assert.assertFalse(handlerB.isHandled());
Assert.assertTrue(handlerC.isHandled());
@ -163,7 +163,7 @@ public class ContextHandlerTest
handlerB.reset();
handlerC.reset();
connectorN.getResponses("GET / HTTP/1.0\n" + "Host: www.example.com.\n\n");
connectorN.getResponse("GET / HTTP/1.0\n" + "Host: www.example.com.\n\n");
Assert.assertTrue(handlerA.isHandled());
Assert.assertFalse(handlerB.isHandled());
Assert.assertFalse(handlerC.isHandled());
@ -171,7 +171,7 @@ public class ContextHandlerTest
handlerB.reset();
handlerC.reset();
connectorN.getResponses("GET / HTTP/1.0\n" + "Host: localhost\n\n");
connectorN.getResponse("GET / HTTP/1.0\n" + "Host: localhost\n\n");
Assert.assertFalse(handlerA.isHandled());
Assert.assertTrue(handlerB.isHandled());
Assert.assertFalse(handlerC.isHandled());
@ -237,39 +237,39 @@ public class ContextHandlerTest
// check that all contexts start normally
server.start();
Assert.assertThat(connector.getResponses("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
Assert.assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo/bar'"));
Assert.assertThat(connector.getResponse("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponse("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
Assert.assertThat(connector.getResponse("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo/bar'"));
// If we stop foobar, then requests will be handled by foo
foobar.stop();
Assert.assertThat(connector.getResponses("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
Assert.assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
Assert.assertThat(connector.getResponse("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponse("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
Assert.assertThat(connector.getResponse("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
// If we shutdown foo then requests will be 503'd
foo.shutdown().get();
Assert.assertThat(connector.getResponses("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("503"));
Assert.assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("503"));
Assert.assertThat(connector.getResponse("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponse("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("503"));
Assert.assertThat(connector.getResponse("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("503"));
// If we stop foo then requests will be handled by root
foo.stop();
Assert.assertThat(connector.getResponses("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponse("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponse("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponse("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
// If we start foo then foobar requests will be handled by foo
foo.start();
Assert.assertThat(connector.getResponses("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
Assert.assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
Assert.assertThat(connector.getResponse("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponse("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
Assert.assertThat(connector.getResponse("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
// If we start foobar then foobar requests will be handled by foobar
foobar.start();
Assert.assertThat(connector.getResponses("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
Assert.assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo/bar'"));
Assert.assertThat(connector.getResponse("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
Assert.assertThat(connector.getResponse("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
Assert.assertThat(connector.getResponse("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo/bar'"));
}

View File

@ -76,7 +76,7 @@ public class AsyncContextDispatchWithQueryStrings
"Host: localhost\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Connection: close\r\n" + "\r\n";
String responseString = _connector.getResponses(request);
String responseString = _connector.getResponse(request);
assertThat(responseString,startsWith("HTTP/1.1 200"));
}

View File

@ -115,7 +115,7 @@ public class AsyncContextTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
String responseString = _connector.getResponses(request);
String responseString = _connector.getResponse(request);
assertThat(responseString, startsWith("HTTP/1.1 200 "));
assertThat(responseString, containsString("doGet:getServletPath:/servletPath"));
@ -131,7 +131,7 @@ public class AsyncContextTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
String responseString = _connector.getResponses(request,10,TimeUnit.MINUTES);
String responseString = _connector.getResponse(request,10,TimeUnit.MINUTES);
assertThat(responseString, startsWith("HTTP/1.1 500 "));
assertThat(responseString, containsString("ERROR: /error"));
@ -147,7 +147,7 @@ public class AsyncContextTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
String responseString = _connector.getResponses(request);
String responseString = _connector.getResponse(request);
assertThat(responseString, startsWith("HTTP/1.1 500 "));
assertThat(responseString, containsString("ERROR: /error"));
@ -163,7 +163,7 @@ public class AsyncContextTest
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Connection: close\r\n" +
"\r\n";
String responseString = _connector.getResponses(request);
String responseString = _connector.getResponse(request);
BufferedReader br = new BufferedReader(new StringReader(responseString));
@ -184,7 +184,7 @@ public class AsyncContextTest
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Connection: close\r\n" +
"\r\n";
String responseString = _connector.getResponses(request);
String responseString = _connector.getResponse(request);
BufferedReader br = new BufferedReader(new StringReader(responseString));
@ -200,7 +200,7 @@ public class AsyncContextTest
{
String request = "GET /ctx/servletPath?dispatch=true HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
+ "Connection: close\r\n" + "\r\n";
String responseString = _connector.getResponses(request);
String responseString = _connector.getResponse(request);
BufferedReader br = parseHeader(responseString);
@ -218,7 +218,7 @@ public class AsyncContextTest
{
String request = "GET /ctx/path%20with%20spaces/servletPath?dispatch=true&queryStringWithEncoding=space%20space HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
+ "Connection: close\r\n" + "\r\n";
String responseString = _connector.getResponses(request);
String responseString = _connector.getResponse(request);
BufferedReader br = parseHeader(responseString);
@ -237,7 +237,7 @@ public class AsyncContextTest
String request = "GET /ctx/servletPath HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
+ "Connection: close\r\n" + "\r\n";
String responseString = _connector.getResponses(request);
String responseString = _connector.getResponse(request);
BufferedReader br = parseHeader(responseString);
@ -252,7 +252,7 @@ public class AsyncContextTest
String request = "GET /ctx/servletPath?dispatch=true HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
+ "Connection: close\r\n" + "\r\n";
String responseString = _connector.getResponses(request);
String responseString = _connector.getResponse(request);
BufferedReader br = parseHeader(responseString);
@ -290,7 +290,7 @@ public class AsyncContextTest
"Connection: close\r\n" +
"\r\n";
String responseString = _connector.getResponses(request);
String responseString = _connector.getResponse(request);
BufferedReader br = parseHeader(responseString);
@ -369,7 +369,7 @@ public class AsyncContextTest
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Connection: close\r\n" +
"\r\n";
String responseString = _connector.getResponses(request);
String responseString = _connector.getResponse(request);
BufferedReader br = new BufferedReader(new StringReader(responseString));
@ -386,7 +386,7 @@ public class AsyncContextTest
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Connection: close\r\n" +
"\r\n";
String responseString = _connector.getResponses(request);
String responseString = _connector.getResponse(request);
BufferedReader br = new BufferedReader(new StringReader(responseString));

View File

@ -145,7 +145,7 @@ public class ComplianceViolations2616Test
req1.append("Connection: close\r\n");
req1.append("\r\n");
String response = connector.getResponses(req1.toString());
String response = connector.getResponse(req1.toString());
assertThat("Response status", response, containsString("HTTP/1.1 200 OK"));
assertThat("Response headers", response, containsString("X-Http-Violation-0: RFC2616<RFC7230: name only header"));
@ -163,7 +163,7 @@ public class ComplianceViolations2616Test
req1.append("Name\r\n");
req1.append("\r\n");
String response = connector.getResponses(req1.toString());
String response = connector.getResponse(req1.toString());
assertThat("Response status", response, containsString("HTTP/1.1 200"));
assertThat("Response headers", response, containsString("X-Http-Violation-0: RFC2616<RFC7230: name only header"));
@ -182,7 +182,7 @@ public class ComplianceViolations2616Test
req1.append("Accept: */*\r\n");
req1.append("\r\n");
String response = connector.getResponses(req1.toString());
String response = connector.getResponse(req1.toString());
assertThat("Response status", response, containsString("HTTP/1.1 200"));
assertThat("Response headers", response, containsString("X-Http-Violation-0: RFC2616<RFC7230: header folding"));

View File

@ -92,7 +92,7 @@ public class DefaultServletRangesTest
{
String response;
response= connector.getResponses(
response= connector.getResponse(
"GET /context/data.txt HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Connection: close\r\n"+
@ -107,7 +107,7 @@ public class DefaultServletRangesTest
{
String response;
response = connector.getResponses(
response = connector.getResponse(
"GET /context/data.txt HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Connection: close\r\n"+
@ -124,7 +124,7 @@ public class DefaultServletRangesTest
{
String response;
response = connector.getResponses(
response = connector.getResponse(
"GET /context/data.txt HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Connection: close\r\n"+
@ -140,7 +140,7 @@ public class DefaultServletRangesTest
public void testMultipleRangeRequests() throws Exception
{
String response;
response = connector.getResponses(
response = connector.getResponse(
"GET /context/data.txt HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Connection: close\r\n"+
@ -165,7 +165,7 @@ public class DefaultServletRangesTest
public void testOpenEndRange() throws Exception
{
String response;
response = connector.getResponses(
response = connector.getResponse(
"GET /context/data.txt HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Connection: close\r\n"+
@ -181,7 +181,7 @@ public class DefaultServletRangesTest
public void testOpenStartRange() throws Exception
{
String response;
response = connector.getResponses(
response = connector.getResponse(
"GET /context/data.txt HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Connection: close\r\n"+
@ -197,7 +197,7 @@ public class DefaultServletRangesTest
public void testUnsatisfiableRanges() throws Exception
{
String response;
response = connector.getResponses(
response = connector.getResponse(
"GET /context/data.txt HTTP/1.1\r\n" +
"Host: localhost\r\n" +
"Connection: close\r\n"+

View File

@ -392,23 +392,23 @@ public class DefaultServletTest
@SuppressWarnings("unused")
ServletHolder jspholder = context.addServlet(NoJspServlet.class, "*.jsp");
String response = connector.getResponses("GET /context/dir/ HTTP/1.0\r\n\r\n");
String response = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
assertResponseContains("403", response);
createFile(index, "<h1>Hello Index</h1>");
response = connector.getResponses("GET /context/dir/ HTTP/1.0\r\n\r\n");
response = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
assertResponseContains("Location: http://0.0.0.0/context/dir/index.html", response);
createFile(inde, "<h1>Hello Inde</h1>");
response = connector.getResponses("GET /context/dir/ HTTP/1.0\r\n\r\n");
response = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
assertResponseContains("Location: http://0.0.0.0/context/dir/index.html", response);
assertTrue(index.delete());
response = connector.getResponses("GET /context/dir/ HTTP/1.0\r\n\r\n");
response = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
assertResponseContains("Location: http://0.0.0.0/context/dir/index.htm", response);
assertTrue(inde.delete());
response = connector.getResponses("GET /context/dir/ HTTP/1.0\r\n\r\n");
response = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
assertResponseContains("403", response);
}

View File

@ -123,7 +123,7 @@ public class DispatcherForwardTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
String response = connector.getResponses(request);
String response = connector.getResponse(request);
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@ -173,7 +173,7 @@ public class DispatcherForwardTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
String response = connector.getResponses(request);
String response = connector.getResponse(request);
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@ -222,7 +222,7 @@ public class DispatcherForwardTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
String response = connector.getResponses(request);
String response = connector.getResponse(request);
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@ -278,7 +278,7 @@ public class DispatcherForwardTest
"Connection: close\r\n" +
"\r\n" +
form;
String response = connector.getResponses(request);
String response = connector.getResponse(request);
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@ -335,7 +335,7 @@ public class DispatcherForwardTest
"Connection: close\r\n" +
"\r\n" +
form;
String response = connector.getResponses(request);
String response = connector.getResponse(request);
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@ -391,7 +391,7 @@ public class DispatcherForwardTest
"Connection: close\r\n" +
"\r\n" +
form;
String response = connector.getResponses(request);
String response = connector.getResponse(request);
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@ -450,7 +450,7 @@ public class DispatcherForwardTest
"Connection: close\r\n" +
"\r\n" +
form;
String response = connector.getResponses(request);
String response = connector.getResponse(request);
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@ -497,7 +497,7 @@ public class DispatcherForwardTest
"Connection: close\r\n" +
"\r\n" +
form;
String response = connector.getResponses(request);
String response = connector.getResponse(request);
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@ -547,7 +547,7 @@ public class DispatcherForwardTest
"Connection: close\r\n" +
"\r\n" +
form;
String response = connector.getResponses(request);
String response = connector.getResponse(request);
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}

View File

@ -115,7 +115,7 @@ public class DispatcherTest
"Content-Length: 0\r\n"+
"\r\n";
String responses = _connector.getResponses("GET /context/ForwardServlet?do=assertforward&do=more&test=1 HTTP/1.0\n\n");
String responses = _connector.getResponse("GET /context/ForwardServlet?do=assertforward&do=more&test=1 HTTP/1.0\n\n");
assertEquals(expected, responses);
}
@ -131,7 +131,7 @@ public class DispatcherTest
"Content-Type: text/html\r\n"+
"Content-Length: 0\r\n"+
"\r\n";
String responses = _connector.getResponses("GET /context/ForwardServlet?do=assertforward&foreign=%d2%e5%ec%ef%e5%f0%e0%f2%f3%f0%e0&test=1 HTTP/1.0\n\n");
String responses = _connector.getResponse("GET /context/ForwardServlet?do=assertforward&foreign=%d2%e5%ec%ef%e5%f0%e0%f2%f3%f0%e0&test=1 HTTP/1.0\n\n");
assertEquals(expected, responses);
}
@ -152,7 +152,7 @@ public class DispatcherTest
"/x x\r\n"+
"/context/EchoURI/x%20x;a=1\r\n";
String responses = _connector.getResponses("GET /context/ForwardServlet;ignore=true?do=req.echo&uri=EchoURI%2Fx%2520x%3Ba=1%3Fb=2 HTTP/1.0\n\n");
String responses = _connector.getResponse("GET /context/ForwardServlet;ignore=true?do=req.echo&uri=EchoURI%2Fx%2520x%3Ba=1%3Fb=2 HTTP/1.0\n\n");
assertEquals(expected, responses);
}
@ -167,7 +167,7 @@ public class DispatcherTest
"HTTP/1.1 200 OK\r\n"+
"\r\n";
String responses = _connector.getResponses("GET /context/IncludeServlet?do=assertinclude&do=more&test=1 HTTP/1.0\n\n");
String responses = _connector.getResponse("GET /context/IncludeServlet?do=assertinclude&do=more&test=1 HTTP/1.0\n\n");
assertEquals(expected, responses);
}
@ -183,7 +183,7 @@ public class DispatcherTest
"HTTP/1.1 200 OK\r\n"+
"\r\n";
String responses = _connector.getResponses("GET /context/ForwardServlet/forwardpath?do=include HTTP/1.0\n\n");
String responses = _connector.getResponse("GET /context/ForwardServlet/forwardpath?do=include HTTP/1.0\n\n");
assertEquals(expected, responses);
}
@ -199,7 +199,7 @@ public class DispatcherTest
"HTTP/1.1 200 OK\r\n"+
"\r\n";
String responses = _connector.getResponses("GET /context/IncludeServlet/includepath?do=forward HTTP/1.0\n\n");
String responses = _connector.getResponse("GET /context/IncludeServlet/includepath?do=forward HTTP/1.0\n\n");
assertEquals(expected, responses);
}
@ -216,7 +216,7 @@ public class DispatcherTest
"\r\n"+
"Roger That!";
String responses = _connector.getResponses("GET /context/dispatch/test?forward=/roger/that HTTP/1.0\n" + "Host: localhost\n\n");
String responses = _connector.getResponse("GET /context/dispatch/test?forward=/roger/that HTTP/1.0\n" + "Host: localhost\n\n");
assertEquals(expected, responses);
}
@ -229,7 +229,7 @@ public class DispatcherTest
String requests="GET /context/dispatch/test?forward=/%2e%2e/roger/that HTTP/1.0\n" + "Host: localhost\n\n";
String responses = _connector.getResponses(requests);
String responses = _connector.getResponse(requests);
assertThat(responses,startsWith("HTTP/1.1 404 "));
}
@ -242,7 +242,7 @@ public class DispatcherTest
String requests="GET /context/dispatch/test?forward=/%252e%252e/roger/that HTTP/1.0\n" + "Host: localhost\n\n";
String responses = _connector.getResponses(requests);
String responses = _connector.getResponse(requests);
assertThat(responses,startsWith("HTTP/1.1 404 "));
}
@ -259,7 +259,7 @@ public class DispatcherTest
"\r\n"+
"Roger That!";
String responses = _connector.getResponses("GET /context/dispatch/test?include=/roger/that HTTP/1.0\n" + "Host: localhost\n\n");
String responses = _connector.getResponse("GET /context/dispatch/test?include=/roger/that HTTP/1.0\n" + "Host: localhost\n\n");
assertEquals(expected, responses);
}
@ -267,7 +267,7 @@ public class DispatcherTest
@Test
public void testWorkingResourceHandler() throws Exception
{
String responses = _connector.getResponses("GET /resource/content.txt HTTP/1.0\n" + "Host: localhost\n\n");
String responses = _connector.getResponse("GET /resource/content.txt HTTP/1.0\n" + "Host: localhost\n\n");
assertTrue(responses.contains("content goes here")); // from inside the context.txt file
}
@ -277,7 +277,7 @@ public class DispatcherTest
{
_contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*");
String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?do=include HTTP/1.0\n" + "Host: localhost\n\n");
String responses = _connector.getResponse("GET /context/resourceServlet/content.txt?do=include HTTP/1.0\n" + "Host: localhost\n\n");
// from inside the context.txt file
Assert.assertNotNull(responses);
@ -290,7 +290,7 @@ public class DispatcherTest
{
_contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*");
String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?do=forward HTTP/1.0\n" + "Host: localhost\n\n");
String responses = _connector.getResponse("GET /context/resourceServlet/content.txt?do=forward HTTP/1.0\n" + "Host: localhost\n\n");
// from inside the context.txt file
assertTrue(responses.contains("content goes here"));
@ -301,7 +301,7 @@ public class DispatcherTest
{
_contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*");
String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?do=include&wrapped=true HTTP/1.0\n" + "Host: localhost\n\n");
String responses = _connector.getResponse("GET /context/resourceServlet/content.txt?do=include&wrapped=true HTTP/1.0\n" + "Host: localhost\n\n");
// from inside the context.txt file
assertTrue(responses.contains("content goes here"));
@ -312,7 +312,7 @@ public class DispatcherTest
{
_contextHandler.addServlet(DispatchToResourceServlet.class, "/resourceServlet/*");
String responses = _connector.getResponses("GET /context/resourceServlet/content.txt?do=forward&wrapped=true HTTP/1.0\n" + "Host: localhost\n\n");
String responses = _connector.getResponse("GET /context/resourceServlet/content.txt?do=forward&wrapped=true HTTP/1.0\n" + "Host: localhost\n\n");
// from inside the context.txt file
assertTrue(responses.contains("content goes here"));
@ -326,11 +326,11 @@ public class DispatcherTest
_contextHandler.addServlet(EchoServlet.class, "/echo/*");
_contextHandler.addFilter(ForwardFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
String rogerResponse = _connector.getResponses("GET /context/ HTTP/1.0\n" + "Host: localhost\n\n");
String rogerResponse = _connector.getResponse("GET /context/ HTTP/1.0\n" + "Host: localhost\n\n");
String echoResponse = _connector.getResponses("GET /context/foo?echo=echoText HTTP/1.0\n" + "Host: localhost\n\n");
String echoResponse = _connector.getResponse("GET /context/foo?echo=echoText HTTP/1.0\n" + "Host: localhost\n\n");
String rechoResponse = _connector.getResponses("GET /context/?echo=echoText HTTP/1.0\n" + "Host: localhost\n\n");
String rechoResponse = _connector.getResponse("GET /context/?echo=echoText HTTP/1.0\n" + "Host: localhost\n\n");
assertTrue(rogerResponse.contains("Roger That!"));
assertTrue(echoResponse.contains("echoText"));

View File

@ -207,7 +207,7 @@ public class GzipHandlerTest
request.setVersion("HTTP/1.0");
request.setHeader("Host","tester");
response = HttpTester.parseResponse(_connector.getResponses(request.generate()));
response = HttpTester.parseResponse(_connector.getResponse(request.generate()));
assertThat(response.getStatus(),is(200));
assertThat(response.get("Content-Encoding"),not(equalToIgnoringCase("gzip")));
@ -235,7 +235,7 @@ public class GzipHandlerTest
request.setHeader("Host","tester");
request.setHeader("accept-encoding","gzip");
response = HttpTester.parseResponse(_connector.getResponses(request.generate()));
response = HttpTester.parseResponse(_connector.getResponse(request.generate()));
assertThat(response.getStatus(),is(200));
assertThat(response.get("Content-Encoding"),Matchers.equalToIgnoringCase("gzip"));
@ -262,7 +262,7 @@ public class GzipHandlerTest
request.setHeader("Host","tester");
request.setHeader("Accept-Encoding","gzip");
response = HttpTester.parseResponse(_connector.getResponses(request.generate()));
response = HttpTester.parseResponse(_connector.getResponse(request.generate()));
assertThat(response.getStatus(),is(200));
assertThat(response.get("Content-Encoding"),not(containsString("gzip")));
@ -319,7 +319,7 @@ public class GzipHandlerTest
request.setHeader("If-None-Match",__contentETag);
request.setHeader("accept-encoding","gzip");
response = HttpTester.parseResponse(_connector.getResponses(request.generate()));
response = HttpTester.parseResponse(_connector.getResponse(request.generate()));
assertThat(response.getStatus(),is(304));
assertThat(response.get("Content-Encoding"),not(Matchers.equalToIgnoringCase("gzip")));
@ -340,7 +340,7 @@ public class GzipHandlerTest
request.setHeader("If-None-Match",__contentETagGzip);
request.setHeader("accept-encoding","gzip");
response = HttpTester.parseResponse(_connector.getResponses(request.generate()));
response = HttpTester.parseResponse(_connector.getResponse(request.generate()));
assertThat(response.getStatus(),is(304));
assertThat(response.get("Content-Encoding"),not(Matchers.equalToIgnoringCase("gzip")));
@ -360,7 +360,7 @@ public class GzipHandlerTest
request.setHeader("accept-encoding","gzip");
request.setURI("/ctx/forward");
response = HttpTester.parseResponse(_connector.getResponses(request.generate()));
response = HttpTester.parseResponse(_connector.getResponse(request.generate()));
assertThat(response.getStatus(),is(200));
assertThat(response.get("Content-Encoding"),Matchers.equalToIgnoringCase("gzip"));
@ -387,7 +387,7 @@ public class GzipHandlerTest
request.setHeader("accept-encoding","gzip");
request.setURI("/ctx/include");
response = HttpTester.parseResponse(_connector.getResponses(request.generate()));
response = HttpTester.parseResponse(_connector.getResponse(request.generate()));
assertThat(response.getStatus(),is(200));
assertThat(response.get("Content-Encoding"),Matchers.equalToIgnoringCase("gzip"));

View File

@ -82,7 +82,7 @@ public class InvokerTest
"\r\n" +
"Invoked TestServlet!";
String response = _connector.getResponses(request);
String response = _connector.getResponse(request);
assertEquals(expectedResponse, response);
}

View File

@ -136,7 +136,7 @@ public class PostServletTest
req.append("0\r\n");
req.append("\r\n");
String resp = connector.getResponses(req.toString(),1,TimeUnit.SECONDS);
String resp = connector.getResponse(req.toString());
assertThat("resp", resp, containsString("HTTP/1.1 200 OK"));
assertThat("resp", resp, containsString("chunked"));

View File

@ -122,18 +122,18 @@ public class ServletContextHandlerTest
assertEquals(2,__testServlets.get());
String response =_connector.getResponses("GET /test1 HTTP/1.0\r\n\r\n");
String response =_connector.getResponse("GET /test1 HTTP/1.0\r\n\r\n");
Assert.assertThat(response,Matchers.containsString("200 OK"));
assertEquals(2,__testServlets.get());
response =_connector.getResponses("GET /test2 HTTP/1.0\r\n\r\n");
response =_connector.getResponse("GET /test2 HTTP/1.0\r\n\r\n");
Assert.assertThat(response,containsString("200 OK"));
assertEquals(2,__testServlets.get());
assertThat(holder0.getServletInstance(),nullValue());
response =_connector.getResponses("GET /test0 HTTP/1.0\r\n\r\n");
response =_connector.getResponse("GET /test0 HTTP/1.0\r\n\r\n");
assertThat(response,containsString("200 OK"));
assertEquals(3,__testServlets.get());
assertThat(holder0.getServletInstance(),notNullValue(Servlet.class));
@ -164,7 +164,7 @@ public class ServletContextHandlerTest
request.append("Host: localhost\n");
request.append("\n");
String response = _connector.getResponses(request.toString());
String response = _connector.getResponse(request.toString());
assertResponseContains("Test", response);
context.addServlet(HelloServlet.class, "/hello");
@ -174,7 +174,7 @@ public class ServletContextHandlerTest
request.append("Host: localhost\n");
request.append("\n");
response = _connector.getResponses(request.toString());
response = _connector.getResponse(request.toString());
assertResponseContains("Hello World", response);
}
@ -197,7 +197,7 @@ public class ServletContextHandlerTest
request.append("Host: localhost\n");
request.append("\n");
String response = _connector.getResponses(request.toString());
String response = _connector.getResponse(request.toString());
assertResponseContains("Test", response);
assertEquals(extra,context.getSessionHandler().getHandler());
@ -241,7 +241,7 @@ public class ServletContextHandlerTest
request.append("Host: localhost\n");
request.append("\n");
String response = _connector.getResponses(request.toString());
String response = _connector.getResponse(request.toString());
assertResponseContains("Test", response);
context.stop();
@ -255,7 +255,7 @@ public class ServletContextHandlerTest
request.append("Host: localhost\n");
request.append("\n");
response = _connector.getResponses(request.toString());
response = _connector.getResponse(request.toString());
assertResponseContains("Hello World", response);
}
@ -273,7 +273,7 @@ public class ServletContextHandlerTest
request.append("Host: localhost\n");
request.append("\n");
String response = _connector.getResponses(request.toString());
String response = _connector.getResponse(request.toString());
assertResponseContains("Test", response);
context.stop();
@ -288,7 +288,7 @@ public class ServletContextHandlerTest
request.append("Host: localhost\n");
request.append("\n");
response = _connector.getResponses(request.toString());
response = _connector.getResponse(request.toString());
assertResponseContains("Hello World", response);
}
@ -357,10 +357,10 @@ public class ServletContextHandlerTest
_server.start();
String response= _connector.getResponses("GET /hello HTTP/1.0\r\n\r\n");
String response= _connector.getResponse("GET /hello HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("200 OK"));
response= _connector.getResponses("GET /other HTTP/1.0\r\n\r\n");
response= _connector.getResponse("GET /other HTTP/1.0\r\n\r\n");
Assert.assertThat(response, Matchers.containsString("404 Fell Through"));
}
@ -381,7 +381,7 @@ public class ServletContextHandlerTest
context.addServlet(DecoratedObjectFactoryServlet.class, "/objfactory/*");
_server.start();
String response= _connector.getResponses("GET /objfactory/ HTTP/1.0\r\n\r\n");
String response= _connector.getResponse("GET /objfactory/ HTTP/1.0\r\n\r\n");
assertThat("Response status code", response, containsString("200 OK"));
String expected = String.format("Attribute[%s] = %s", DecoratedObjectFactory.ATTR, DecoratedObjectFactory.class.getName());
@ -408,7 +408,7 @@ public class ServletContextHandlerTest
context.addServlet(DecoratedObjectFactoryServlet.class, "/objfactory/*");
_server.start();
String response= _connector.getResponses("GET /objfactory/ HTTP/1.0\r\n\r\n");
String response= _connector.getResponse("GET /objfactory/ HTTP/1.0\r\n\r\n");
assertThat("Response status code", response, containsString("200 OK"));
String expected = String.format("Attribute[%s] = %s", DecoratedObjectFactory.ATTR, DecoratedObjectFactory.class.getName());

View File

@ -113,7 +113,7 @@ public class ServletContextResourcesTest
req1.append("Connection: close\r\n");
req1.append("\r\n");
String response = connector.getResponses(req1.toString());
String response = connector.getResponse(req1.toString());
assertThat("Response", response, containsString("Resource '/': <null>"));
}
@ -128,7 +128,7 @@ public class ServletContextResourcesTest
req1.append("Connection: close\r\n");
req1.append("\r\n");
String response = connector.getResponses(req1.toString());
String response = connector.getResponse(req1.toString());
assertThat("Response", response, containsString("Resource '/content.txt': content goes here"));
}
}

View File

@ -92,7 +92,7 @@ public class ConcatServletTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
String response = connector.getResponses(request);
String response = connector.getResponse(request);
try (BufferedReader reader = new BufferedReader(new StringReader(response)))
{
while (true)
@ -140,7 +140,7 @@ public class ConcatServletTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
String response = connector.getResponses(request);
String response = connector.getResponse(request);
Assert.assertTrue(response.startsWith("HTTP/1.1 404 "));
// Make sure ConcatServlet behaves well if it's case insensitive.
@ -150,7 +150,7 @@ public class ConcatServletTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
response = connector.getResponses(request);
response = connector.getResponse(request);
Assert.assertTrue(response.startsWith("HTTP/1.1 404 "));
// Make sure ConcatServlet behaves well if encoded.
@ -160,7 +160,7 @@ public class ConcatServletTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
response = connector.getResponses(request);
response = connector.getResponse(request);
Assert.assertTrue(response.startsWith("HTTP/1.1 404 "));
// Make sure ConcatServlet cannot see file system files.
@ -170,7 +170,7 @@ public class ConcatServletTest
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n";
response = connector.getResponses(request);
response = connector.getResponse(request);
Assert.assertTrue(response.startsWith("HTTP/1.1 404 "));
}
}