Examples of HttpClientConnection


Examples of com.heroku.api.connection.HttpClientConnection

    }

    @Provides()
    FutureConnection getConnectionImpl() throws IOException {
        try {
            return new HttpClientConnection();
        } catch (RequestFailedException e) {
            System.out.println(e.getMessage());
            System.out.println(e.getStatusCode());
            System.out.println(e.getResponseBody());
            System.out.flush();
View Full Code Here

Examples of io.undertow.client.HttpClientConnection

        this.destination = destination;
    }

    public void handleRequest(final HttpServerExchange exchange) {
        final HttpServerConnection serverConnection = exchange.getConnection();
        final HttpClientConnection clientConnection = serverConnection.getAttachment(proxyConnection);
        if (clientConnection == null) {
            exchange.dispatch(SameThreadExecutor.INSTANCE, new Runnable() {
                @Override
                public void run() {
                    client.connect(exchange.getIoThread(), destination, OptionMap.EMPTY).addNotifier(notifier, exchange);
View Full Code Here

Examples of org.apache.http.HttpClientConnection

        HttpPost request = new HttpPost("/echo/");
        request.setHeader("Host", target.getHostName());
        request.setEntity(new StringEntity(message, charset));

        HttpClientConnection conn = connectTo(target);

        httpContext.setAttribute(
                ExecutionContext.HTTP_CONNECTION, conn);
        httpContext.setAttribute(
                ExecutionContext.HTTP_TARGET_HOST, target);
        httpContext.setAttribute(
                ExecutionContext.HTTP_REQUEST, request);

        request.setParams(
                new DefaultedHttpParams(request.getParams(), defaultParams));
        httpExecutor.preProcess
            (request, httpProcessor, httpContext);
        HttpResponse response = httpExecutor.execute
            (request, conn, httpContext);
        response.setParams(
                new DefaultedHttpParams(response.getParams(), defaultParams));
        httpExecutor.postProcess
            (response, httpProcessor, httpContext);

        assertEquals("wrong status in response", HttpStatus.SC_OK,
                     response.getStatusLine().getStatusCode());

        String received = EntityUtils.toString(response.getEntity());
        conn.close();

        assertEquals("wrong echo", message, received);
    }
View Full Code Here

Examples of org.hsqldb.HTTPClientConnection

                sessionProxy = new HSQLClientConnection(host, port, path,
                        database, isTLS, user, password);
                isNetConn = true;
            } else if (connType == DatabaseURL.S_HTTP
                       || connType == DatabaseURL.S_HTTPS) {
                sessionProxy = new HTTPClientConnection(host, port, path,
                        database, isTLS, user, password);
                isNetConn = true;
            } else {    // alias: type not yet implemented
                throw Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
            }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

    public void testCon() throws Exception {
       
        HttpServer server = new HttpServer(new RequestHandler());
        server.start();
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());

        FutureResponseHandler hdl = new FutureResponseHandler();
        BodyDataSink ds = con.send(new HttpRequestHeader("POST", "http://localhost:"  +server.getLocalPort() + "/", "text/plain"), 200, hdl);
        for (int i = 0; i < 20; i++) {
            ds.write("0123456789");
            QAUtil.sleep(50);
        }
        ds.close();
           
        IHttpResponse response = hdl.get();
        Assert.assertEquals(200, response.getStatus());
       
        con.close();
        server.close();
    }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

       
        RequestHandler reqHdl = new RequestHandler();
        HttpServer server = new HttpServer(reqHdl);
        server.start();
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
       
        FutureResponseHandler respHdl = new FutureResponseHandler();
        BodyDataSink dataSink = con.send(new HttpRequestHeader("POST", "http://localhost:" + server.getLocalPort() + "/"), respHdl);
       
        dataSink.write("test");
        QAUtil.sleep(200);
       
        dataSink.write("OneTwo");
        QAUtil.sleep(200);
       
        dataSink.write("End");
        dataSink.close();
       
        IHttpResponse response = respHdl.getResponse();
       
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("testOneTwoEnd", DataConverter.toString(reqHdl.getData()));
       
        con.close();
        server.close();
    }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

       
        RequestHandler reqHdl = new RequestHandler();
        HttpServer server = new HttpServer(reqHdl);
        server.start();
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
       
        File file = QAUtil.createTestfile_4k();
       
        FutureResponseHandler respHdl = new FutureResponseHandler();
        BodyDataSink dataSink = con.send(new HttpRequestHeader("POST", "http://localhost:" + server.getLocalPort() + "/"), respHdl);
       
       
        RandomAccessFile raf = new RandomAccessFile(file, "r");
        FileChannel fc = raf.getChannel();
        dataSink.transferFrom(fc);
        fc.close();
        raf.close();
        dataSink.close();
       
        IHttpResponse response = respHdl.getResponse();
       
        Assert.assertEquals(200, response.getStatus());
        Assert.assertTrue(QAUtil.isEquals(file, reqHdl.getData()));
       
        file.delete();
        con.close();
        server.close();
    }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

       
        RequestHandler2 reqHdl = new RequestHandler2();
        HttpServer server = new HttpServer(reqHdl);
        server.start();
       
        HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
       
        File file = QAUtil.createTestfile_4k();
       
        FutureResponseHandler respHdl = new FutureResponseHandler();
        BodyDataSink dataSink = con.send(new HttpRequestHeader("POST", "http://localhost:" + server.getLocalPort() + "/"), respHdl);
       
       
        RandomAccessFile raf = new RandomAccessFile(file, "r");
        FileChannel fc = raf.getChannel();
        dataSink.transferFrom(fc);
        fc.close();
        raf.close();
        dataSink.close();
       
        IHttpResponse response = respHdl.getResponse();
       
        Assert.assertEquals(200, response.getStatus());
        Assert.assertTrue(QAUtil.isEquals(file, "ISO-8859-1", reqHdl.getData()));
       
        file.delete();
        con.close();
        server.close();
    }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

      server.start();
     
      NonBlockingConnectionPool pool = new NonBlockingConnectionPool();
             
        for (int i = 0; i < 1000; i++) {
            HttpClientConnection httpCon = new HttpClientConnection(pool.getNonBlockingConnection("localhost", server.getLocalPort()));
            IHttpResponse resp = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
       
            InputStream in = Channels.newInputStream(resp.getBlockingBody());
            in.close();
               
            httpCon.close();
        }
       
        pool.close();
  }
View Full Code Here

Examples of org.xlightweb.client.HttpClientConnection

      IServer server = new Server(dh);
      server.start();
     
      HttpClientConnectionPool pool = new HttpClientConnectionPool();
             
      HttpClientConnection httpCon = pool.getHttpClientConnection("localhost", server.getLocalPort());
      IHttpResponse resp = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
       
      InputStream in = Channels.newInputStream(resp.getBlockingBody());
      in.close();

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.