Package org.xlightweb.client

Examples of org.xlightweb.client.HttpClientConnection.send()


     
      HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
     
     
      FutureResponseHandler respHandler = new FutureResponseHandler();
      BodyDataSink dataSink = con.send(new HttpRequestHeader("POST", "http://localhost:" + server.getLocalPort() + "/"), respHandler);
      dataSink.write("test");
      QAUtil.sleep(300);
     
      dataSink.write("123");
      QAUtil.sleep(300);
View Full Code Here


      HttpServer server = new HttpServer(new RequestHandler());
      server.start();
     
     
      HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
      IFutureResponse futureResponse = con.send(new GetRequest("http://localhost:" + server.getLocalPort() + "/?pauseMillis=10"));

      IHttpResponse response = futureResponse.getResponse();
     
      Assert.assertTrue(futureResponse.isDone());
      Assert.assertFalse(futureResponse.isCancelled());
View Full Code Here

        HttpServer server = new HttpServer(new RequestHandler());
        server.start();
       
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
        IFutureResponse futureResponse = con.send(new GetRequest("http://localhost:" + server.getLocalPort() + "/?pauseMillis=500"));

        try {
            futureResponse.getResponse(100, TimeUnit.MILLISECONDS);
            Assert.fail("SocketTimeoutException expected");
        } catch (SocketTimeoutException expected) { }
View Full Code Here

        HttpServer server = new HttpServer(new RequestHandler());
        server.start();
       
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
        IFutureResponse futureResponse = con.send(new GetRequest("http://localhost:" + server.getLocalPort() + "/?pauseMillis=500"));

        futureResponse.cancel(true);
       
        Assert.assertTrue(futureResponse.isCancelled());
        Assert.assertTrue(futureResponse.isDone());
View Full Code Here

   
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   
    ResponseHandler respHdl = new ResponseHandler();
    con.send(new GetRequest("/"), respHdl);
   
    QAUtil.sleep(1000);
   
    Assert.assertNotNull(respHdl.getException());
   
View Full Code Here

   
   
    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
   
    ResponseHandler2 respHdl = new ResponseHandler2();
    con.send(new GetRequest("/"), respHdl);
   
    QAUtil.sleep(1000);
   
    Assert.assertNotNull(respHdl.ioeRef.get());
    Assert.assertTrue(respHdl.ioeRef.get() instanceof ProtocolException);
View Full Code Here

    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    con.setOption(IConnection.SO_RCVBUF, 64);
    con.suspendReceiving();

    FutureResponseHandler respHdl = new FutureResponseHandler();
    con.send(new GetRequest("/" + file.getName()), respHdl);

    QAUtil.sleep(1000);
    con.resumeReceiving();

   
View Full Code Here

      HttpClientConnection con = new HttpClientConnection(nbc);
     
      IHttpRequest request = new GetRequest("http://www.gmx.com/doesNotExist.html");
     
      ResponseHandler respHdl = new ResponseHandler();
      con.send(request, respHdl);
 
      while (respHdl.getResponse() == null) {
        QAUtil.sleep(100);
      }
     
View Full Code Here

    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    con.setResponseTimeoutMillis(1000);

    ResponseHandler hdl = new ResponseHandler();
    con.send(new GetRequest("/"), hdl);


    QAUtil.sleep(2000);
    Assert.assertEquals(1, hdl.getCountIOException());
View Full Code Here

    HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
    con.setOption(IConnection.SO_RCVBUF, 64);
    con.suspendReceiving();

    FutureResponseHandler respHdl = new FutureResponseHandler();
    con.send(new GetRequest("/" + file.getName()), respHdl);

    QAUtil.sleep(1000);
    con.resumeReceiving();

   
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.