Package org.xsocket.connection

Examples of org.xsocket.connection.BlockingConnection


  public void testAutoContinue() throws Exception {

    HttpServer server = new HttpServer(new ItWorksHandler());
    server.start();
   
    IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
    con.write("POST / HTTP/1.1\r\n" +
          "Host: localhost\r\n" +
          "User-Agent: me\r\n" +
          "Expect: 100-Continue\r\n" +
          "Content-Length: 2000\r\n" +
          "\r\n");
   
   
    String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
    Assert.assertTrue(header.indexOf("100") != -1);
   
   
    con.write(QAUtil.generateByteArray(2000));
   
    header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
    Assert.assertTrue(header.indexOf("200") != -1);
   
   
   
    con.close();
    server.close();
  }
View Full Code Here


        ContinueHandler hdl = new ContinueHandler();
        HttpServer server = new HttpServer(hdl);
        server.start();
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("POST / HTTP/1.1\r\n" +
                  "Host: localhost\r\n" +
                  "User-Agent: me\r\n" +
                  "Expect: 100-Continue\r\n" +
                  "Content-Length: 2000\r\n" +
                  "\r\n");
       
       
        String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("100") != -1);
       
        QAUtil.sleep(300);
       
        Assert.assertTrue(hdl.is100ContinueSent());
       
        con.write(QAUtil.generateByteArray(2000));

        header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("200") != -1);
        int length = QAUtil.readContentLength(header);
        String txt = con.readStringByLength(length);
        Assert.assertEquals("OK", txt);
       
       
       
        con.close();
        server.close();
    }
View Full Code Here

        ContinueHandler2 hdl = new ContinueHandler2();
        HttpServer server = new HttpServer(hdl);
        server.start();
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("POST / HTTP/1.1\r\n" +
                  "Host: localhost\r\n" +
                  "User-Agent: me\r\n" +
                  "Expect: 100-Continue\r\n" +
                  "Content-Length: 2000\r\n" +
                  "\r\n");
       
       
        String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("100") != -1);
        QAUtil.sleep(300);
       
        Assert.assertTrue(hdl.is100ContinueSent());
       
        con.write(QAUtil.generateByteArray(2000));

        header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("200") != -1);
        int length = QAUtil.readContentLength(header);
        String txt = con.readStringByLength(length);
        Assert.assertEquals("OK", txt);
       
       
       
        con.close();
        server.close();
    }
View Full Code Here

        };

        HttpServer server = new HttpServer(hdl);
        server.start();
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("POST / HTTP/1.1\r\n" +
                  "Host: localhost\r\n" +
                  "User-Agent: me\r\n" +
                  "Expect: 100-Continue\r\n" +
                  "Content-Length: 2000\r\n" +
                  "\r\n");
       
       
        String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("100") != -1);
       
        QAUtil.sleep(300);
       
        con.write(QAUtil.generateByteArray(2000));

        header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("200") != -1);
        int length = QAUtil.readContentLength(header);
        String txt = con.readStringByLength(length);
        Assert.assertEquals("OK", txt);
       
       
       
        con.close();
        server.close();
    }
View Full Code Here

       
       
        HttpServer server = new HttpServer(hdl);
        server.start();
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("POST / HTTP/1.1\r\n" +
                  "Host: localhost\r\n" +
                  "User-Agent: me\r\n" +
                  "Expect: 100-Continue\r\n" +
                  "Content-Length: 2000\r\n" +
                  "\r\n");
       
       
        String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("100") != -1);
       
        QAUtil.sleep(300);
       
        con.write(QAUtil.generateByteArray(2000));

        header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("200") != -1);
        int length = QAUtil.readContentLength(header);
        String txt = con.readStringByLength(length);
        Assert.assertEquals("OK", txt);
       
       
       
        con.close();
        server.close();
    }
View Full Code Here

        MissingAnnotationContinueHandler hdl = new MissingAnnotationContinueHandler();
        HttpServer server = new HttpServer(hdl);
        server.start();
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("POST / HTTP/1.1\r\n" +
                  "Host: localhost\r\n" +
                  "User-Agent: me\r\n" +
                  "Expect: 100-Continue\r\n" +
                  "Content-Length: 2000\r\n" +
                  "\r\n");
       
       
        String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("100") != -1);
        Assert.assertFalse(hdl.is100ContinueSent());
       
        con.write(QAUtil.generateByteArray(2000));

        header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("200") != -1);
        int length = QAUtil.readContentLength(header);
        String txt = con.readStringByLength(length);
        Assert.assertEquals("OK", txt);
       
       
       
        con.close();
        server.close();
    }
View Full Code Here

        chain.addLast(new ItWorksHandler());
       
        HttpServer server = new HttpServer(chain);
        server.start();
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("POST / HTTP/1.1\r\n" +
                  "Host: localhost\r\n" +
                  "User-Agent: me\r\n" +
                  "Expect: 100-Continue\r\n" +
                  "Content-Length: 2000\r\n" +
                  "\r\n");
       
       
        String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("100") != -1);
       
        con.write(QAUtil.generateByteArray(2000));

        header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("200") != -1);
        Assert.assertTrue(header.indexOf("X-Intercepted") != -1);
        int length = QAUtil.readContentLength(header);
        String txt = con.readStringByLength(length);
        Assert.assertEquals("OK", txt);
       
       
       
        con.close();
        server.close();
    }
View Full Code Here

       
       
        HttpServer server = new HttpServer(outerChain);
        server.start();
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("POST / HTTP/1.1\r\n" +
                  "Host: localhost\r\n" +
                  "User-Agent: me\r\n" +
                  "Expect: 100-Continue\r\n" +
                  "Content-Length: 2000\r\n" +
                  "\r\n");
       
       
        String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("100") != -1);
       
        con.write(QAUtil.generateByteArray(2000));

        header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("200") != -1);
        Assert.assertTrue(header.indexOf("X-Intercepted1") != -1);
        Assert.assertTrue(header.indexOf("X-Intercepted2") != -1);
        int length = QAUtil.readContentLength(header);
        String txt = con.readStringByLength(length);
        Assert.assertEquals("OK", txt);
       
       
       
        con.close();
        server.close();
    }
View Full Code Here

       
       
        HttpServer server = new HttpServer(outerChain);
        server.start();
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("POST / HTTP/1.1\r\n" +
                  "Host: localhost\r\n" +
                  "User-Agent: me\r\n" +
                  "Expect: 100-Continue\r\n" +
                  "Content-Length: 2000\r\n" +
                  "\r\n");
       
       
        String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("100") != -1);
       
        con.write(QAUtil.generateByteArray(2000));

        header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("200") != -1);
        Assert.assertTrue(header.indexOf("X-Intercepted1") != -1);
        Assert.assertTrue(header.indexOf("X-Intercepted2") != -1);
        int length = QAUtil.readContentLength(header);
        String txt = con.readStringByLength(length);
        Assert.assertEquals("OK", txt);
       
       
       
        con.close();
        server.close();
    }
View Full Code Here

       
       
        HttpServer server = new HttpServer(outerChain);
        server.start();
       
        IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
        con.write("POST / HTTP/1.1\r\n" +
                  "Host: localhost\r\n" +
                  "User-Agent: me\r\n" +
                  "Expect: 100-Continue\r\n" +
                  "Content-Length: 2000\r\n" +
                  "\r\n");
       
       
        String header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("100") != -1);
        Assert.assertTrue(hdl.is100ContinueSent());
       
        con.write(QAUtil.generateByteArray(2000));

        header = con.readStringByDelimiter("\r\n\r\n") + "\r\n";
        Assert.assertTrue(header.indexOf("200") != -1);
        Assert.assertTrue(header.indexOf("X-Intercepted1") != -1);
        Assert.assertTrue(header.indexOf("X-Intercepted2") != -1);
        int length = QAUtil.readContentLength(header);
        String txt = con.readStringByLength(length);
        Assert.assertEquals("OK", txt);
       
       
       
        con.close();
        server.close();
    }
View Full Code Here

TOP

Related Classes of org.xsocket.connection.BlockingConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.