Java 类org.apache.catalina.startup.SimpleHttpClient 实例源码

项目:tomcat7    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithUnknownExpectation() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Expect: unknoen" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF;

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse417());
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithUnknownExpectation() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Expect: unknoen" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF;

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse417());
}
项目:apache-tomcat-7.0.57    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithUnknownExpectation() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Expect: unknoen" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF;

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse417());
}
项目:apache-tomcat-7.0.57    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithUnknownExpectation() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Expect: unknoen" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF;

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse417());
}
项目:tomcat7    文件:TestAbstractHttp11Processor.java   
@Test
public void testResponseWithErrorChunked() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctxt = tomcat.addContext("", null);

    // Add protected servlet
    Tomcat.addServlet(ctxt, "ChunkedResponseWithErrorServlet",
            new ResponseWithErrorServlet(true));
    ctxt.addServletMapping("/*", "ChunkedResponseWithErrorServlet");

    tomcat.start();

    String request =
            "GET /anything HTTP/1.1" + SimpleHttpClient.CRLF +
            "Host: any" + SimpleHttpClient.CRLF +
             SimpleHttpClient.CRLF;

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();

    // Expected response is a 200 response followed by an incomplete chunked
    // body.
    assertTrue(client.isResponse200());
    // There should not be an end chunk
    assertFalse(client.getResponseBody().endsWith("0"));
    // The last portion of text should be there
    assertTrue(client.getResponseBody().endsWith("line03"));
}
项目:tomcat7    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEVoid() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: void" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:tomcat7    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEBuffered() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: buffered" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:tomcat7    文件:TestAbstractHttp11Processor.java   
private void doTestWithTEChunked(boolean withCL)
        throws Exception {

    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        (withCL ? "Content-length: 1" + SimpleHttpClient.CRLF : "") +
        "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        "Connection: close" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "9" + SimpleHttpClient.CRLF +
        "test=data" + SimpleHttpClient.CRLF +
        "0" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF;

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse200());
    assertTrue(client.getResponseBody().contains("test - data"));
}
项目:tomcat7    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEIdentity() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: identity" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        "Connection: close" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse200());
    assertTrue(client.getResponseBody().contains("test - data"));
}
项目:tomcat7    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTESavedRequest() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: savedrequest" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:tomcat7    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEUnsupported() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: unsupported" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:tomcat7    文件:TestChunkedInputFilter.java   
@Test
public void testNoTrailingHeaders() throws Exception {
    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    Tomcat.addServlet(ctx, "servlet", new EchoHeaderServlet(true));
    ctx.addServletMapping("/", "servlet");

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        "Connection: close" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "3" + SimpleHttpClient.CRLF +
        "a=0" + SimpleHttpClient.CRLF +
        "4" + SimpleHttpClient.CRLF +
        "&b=1" + SimpleHttpClient.CRLF +
        "0" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF;

    TrailerClient client =
            new TrailerClient(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertEquals("nullnull7nullnull", client.getResponseBody());
}
项目:tomcat7    文件:TestInternalInputBuffer.java   
@Test
public void testBug51557Continuation() {

    Bug51557Client client = new Bug51557Client("X-Bug=51557NoColon",
            "foo" + SimpleHttpClient.CRLF + " bar");

    client.doRequest();
    assertTrue(client.isResponse200());
    assertEquals("abcd", client.getResponseBody());
    assertTrue(client.isResponseBodyOK());
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestAbstractHttp11Processor.java   
@Test
public void testResponseWithErrorChunked() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctxt = tomcat.addContext("", null);

    // Add protected servlet
    Tomcat.addServlet(ctxt, "ChunkedResponseWithErrorServlet",
            new ResponseWithErrorServlet(true));
    ctxt.addServletMapping("/*", "ChunkedResponseWithErrorServlet");

    tomcat.start();

    String request =
            "GET /anything HTTP/1.1" + SimpleHttpClient.CRLF +
            "Host: any" + SimpleHttpClient.CRLF +
             SimpleHttpClient.CRLF;

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();

    // Expected response is a 200 response followed by an incomplete chunked
    // body.
    assertTrue(client.isResponse200());
    // There should not be an end chunk
    assertFalse(client.getResponseBody().endsWith("0"));
    // The last portion of text should be there
    assertTrue(client.getResponseBody().endsWith("line03"));
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEVoid() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: void" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEBuffered() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: buffered" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestAbstractHttp11Processor.java   
private void doTestWithTEChunked(boolean withCL)
        throws Exception {

    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        (withCL ? "Content-length: 1" + SimpleHttpClient.CRLF : "") +
        "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        "Connection: close" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "9" + SimpleHttpClient.CRLF +
        "test=data" + SimpleHttpClient.CRLF +
        "0" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF;

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse200());
    assertTrue(client.getResponseBody().contains("test - data"));
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEIdentity() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: identity" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        "Connection: close" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse200());
    assertTrue(client.getResponseBody().contains("test - data"));
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTESavedRequest() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: savedrequest" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEUnsupported() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: unsupported" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestChunkedInputFilter.java   
@Test
public void testNoTrailingHeaders() throws Exception {
    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    Tomcat.addServlet(ctx, "servlet", new EchoHeaderServlet(true));
    ctx.addServletMapping("/", "servlet");

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        "Connection: close" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "3" + SimpleHttpClient.CRLF +
        "a=0" + SimpleHttpClient.CRLF +
        "4" + SimpleHttpClient.CRLF +
        "&b=1" + SimpleHttpClient.CRLF +
        "0" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF;

    TrailerClient client =
            new TrailerClient(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertEquals("nullnull7nullnull", client.getResponseBody());
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestInternalInputBuffer.java   
@Test
public void testBug51557Continuation() {

    Bug51557Client client = new Bug51557Client("X-Bug=51557NoColon",
            "foo" + SimpleHttpClient.CRLF + " bar");

    client.doRequest();
    assertTrue(client.isResponse200());
    assertEquals("abcd", client.getResponseBody());
    assertTrue(client.isResponseBodyOK());
}
项目:class-guard    文件:TestMaxConnections.java   
private synchronized void init() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    Context root = tomcat.addContext("", SimpleHttpClient.TEMP_DIR);
    Tomcat.addServlet(root, "Simple", new SimpleServlet());
    root.addServletMapping("/test", "Simple");
    tomcat.getConnector().setProperty("maxKeepAliveRequests", "1");
    tomcat.getConnector().setProperty("maxThreads", "10");
    tomcat.getConnector().setProperty("soTimeout", "20000");
    tomcat.getConnector().setProperty("keepAliveTimeout", "50000");
    tomcat.getConnector().setProperty(
            "maxConnections", Integer.toString(MAX_CONNECTIONS));
    tomcat.getConnector().setProperty("acceptCount", "1");
    tomcat.start();
}
项目:class-guard    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEVoid() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: void" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:class-guard    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEBuffered() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: buffered" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:class-guard    文件:TestAbstractHttp11Processor.java   
private void doTestWithTEChunked(boolean withCL)
        throws Exception {

    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        (withCL ? "Content-length: 1" + SimpleHttpClient.CRLF : "") +
        "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        "Connection: close" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "9" + SimpleHttpClient.CRLF +
        "test=data" + SimpleHttpClient.CRLF +
        "0" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF;

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse200());
    assertTrue(client.getResponseBody().contains("test - data"));
}
项目:class-guard    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEIdentity() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: identity" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        "Connection: close" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse200());
    assertTrue(client.getResponseBody().contains("test - data"));
}
项目:class-guard    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTESavedRequest() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: savedrequest" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:class-guard    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEUnsupported() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: unsupported" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:class-guard    文件:TestChunkedInputFilter.java   
@Test
public void testNoTrailingHeaders() throws Exception {
    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // Must have a real docBase - just use temp
    Context ctx =
        tomcat.addContext("", System.getProperty("java.io.tmpdir"));

    Tomcat.addServlet(ctx, "servlet", new EchoHeaderServlet(true));
    ctx.addServletMapping("/", "servlet");

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        "Connection: close" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "3" + SimpleHttpClient.CRLF +
        "a=0" + SimpleHttpClient.CRLF +
        "4" + SimpleHttpClient.CRLF +
        "&b=1" + SimpleHttpClient.CRLF +
        "0" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF;

    TrailerClient client =
            new TrailerClient(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertEquals("nullnull7nullnull", client.getResponseBody());
}
项目:class-guard    文件:TestInternalInputBuffer.java   
@Test
public void testBug51557Continuation() {

    Bug51557Client client = new Bug51557Client("X-Bug=51557NoColon",
            "foo" + SimpleHttpClient.CRLF + " bar");

    client.doRequest();
    assertTrue(client.isResponse200());
    assertEquals("abcd", client.getResponseBody());
    assertTrue(client.isResponseBodyOK());
}
项目:apache-tomcat-7.0.57    文件:TestMaxConnections.java   
private synchronized void init() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    Context root = tomcat.addContext("", SimpleHttpClient.TEMP_DIR);
    Tomcat.addServlet(root, "Simple", new SimpleServlet());
    root.addServletMapping("/test", "Simple");
    tomcat.getConnector().setProperty("maxKeepAliveRequests", "1");
    tomcat.getConnector().setProperty("maxThreads", "10");
    tomcat.getConnector().setProperty("soTimeout", "20000");
    tomcat.getConnector().setProperty("keepAliveTimeout", "50000");
    tomcat.getConnector().setProperty(
            "maxConnections", Integer.toString(MAX_CONNECTIONS));
    tomcat.getConnector().setProperty("acceptCount", "1");
    tomcat.start();
}
项目:apache-tomcat-7.0.57    文件:TestAbstractHttp11Processor.java   
@Test
public void testResponseWithErrorChunked() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Must have a real docBase - just use temp
    Context ctxt = tomcat.addContext("", System.getProperty("java.io.tmpdir"));

    // Add protected servlet
    Tomcat.addServlet(ctxt, "ChunkedResponseWithErrorServlet",
            new ResponseWithErrorServlet(true));
    ctxt.addServletMapping("/*", "ChunkedResponseWithErrorServlet");

    tomcat.start();

    String request =
            "GET /anything HTTP/1.1" + SimpleHttpClient.CRLF +
            "Host: any" + SimpleHttpClient.CRLF +
             SimpleHttpClient.CRLF;

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();

    // Expected response is a 200 response followed by an incomplete chunked
    // body.
    assertTrue(client.isResponse200());
    // There should not be an end chunk
    assertFalse(client.getResponseBody().endsWith("0"));
    // The last portion of text should be there
    assertTrue(client.getResponseBody().endsWith("line03"));
}
项目:apache-tomcat-7.0.57    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEVoid() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: void" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:apache-tomcat-7.0.57    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEBuffered() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: buffered" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:apache-tomcat-7.0.57    文件:TestAbstractHttp11Processor.java   
private void doTestWithTEChunked(boolean withCL)
        throws Exception {

    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        (withCL ? "Content-length: 1" + SimpleHttpClient.CRLF : "") +
        "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        "Connection: close" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "9" + SimpleHttpClient.CRLF +
        "test=data" + SimpleHttpClient.CRLF +
        "0" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF;

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse200());
    assertTrue(client.getResponseBody().contains("test - data"));
}
项目:apache-tomcat-7.0.57    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEIdentity() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: identity" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        "Connection: close" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse200());
    assertTrue(client.getResponseBody().contains("test - data"));
}
项目:apache-tomcat-7.0.57    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTESavedRequest() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: savedrequest" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:apache-tomcat-7.0.57    文件:TestAbstractHttp11Processor.java   
@Test
public void testWithTEUnsupported() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Use the normal Tomcat ROOT context
    File root = new File("test/webapp-3.0");
    tomcat.addWebapp("", root.getAbsolutePath());

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: unsupported" + SimpleHttpClient.CRLF +
        "Content-Length: 9" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "test=data";

    Client client = new Client(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertTrue(client.isResponse501());
}
项目:apache-tomcat-7.0.57    文件:TestChunkedInputFilter.java   
@Test
public void testNoTrailingHeaders() throws Exception {
    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // Must have a real docBase - just use temp
    Context ctx =
        tomcat.addContext("", System.getProperty("java.io.tmpdir"));

    Tomcat.addServlet(ctx, "servlet", new EchoHeaderServlet(true));
    ctx.addServletMapping("/", "servlet");

    tomcat.start();

    String request =
        "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
        "Host: any" + SimpleHttpClient.CRLF +
        "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
        "Content-Type: application/x-www-form-urlencoded" +
                SimpleHttpClient.CRLF +
        "Connection: close" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF +
        "3" + SimpleHttpClient.CRLF +
        "a=0" + SimpleHttpClient.CRLF +
        "4" + SimpleHttpClient.CRLF +
        "&b=1" + SimpleHttpClient.CRLF +
        "0" + SimpleHttpClient.CRLF +
        SimpleHttpClient.CRLF;

    TrailerClient client =
            new TrailerClient(tomcat.getConnector().getLocalPort());
    client.setRequest(new String[] {request});

    client.connect();
    client.processRequest();
    assertEquals("nullnull7nullnull", client.getResponseBody());
}