Search in sources :

Example 1 with HttpClientTransportOverFCGI

use of org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI in project jetty.project by eclipse.

the class AbstractHttpClientServerTest method start.

public void start(Handler handler) throws Exception {
    server = new Server();
    ServerFCGIConnectionFactory fcgiConnectionFactory = new ServerFCGIConnectionFactory(new HttpConfiguration());
    serverBufferPool = new LeakTrackingByteBufferPool(new MappedByteBufferPool.Tagged());
    connector = new ServerConnector(server, null, null, serverBufferPool, 1, Math.max(1, Runtime.getRuntime().availableProcessors() / 2), fcgiConnectionFactory);
    //        connector.setPort(9000);
    server.addConnector(connector);
    server.setHandler(handler);
    server.start();
    QueuedThreadPool executor = new QueuedThreadPool();
    executor.setName(executor.getName() + "-client");
    client = new HttpClient(new HttpClientTransportOverFCGI(1, false, "") {

        @Override
        public HttpDestination newHttpDestination(Origin origin) {
            return new HttpDestinationOverFCGI(client, origin) {

                @Override
                protected DuplexConnectionPool newConnectionPool(HttpClient client) {
                    return new LeakTrackingConnectionPool(this, client.getMaxConnectionsPerDestination(), this) {

                        @Override
                        protected void leaked(LeakDetector.LeakInfo leakInfo) {
                            connectionLeaks.incrementAndGet();
                        }
                    };
                }
            };
        }
    }, null);
    client.setExecutor(executor);
    clientBufferPool = new LeakTrackingByteBufferPool(new MappedByteBufferPool.Tagged());
    client.setByteBufferPool(clientBufferPool);
    client.start();
}
Also used : Origin(org.eclipse.jetty.client.Origin) HttpDestinationOverFCGI(org.eclipse.jetty.fcgi.client.http.HttpDestinationOverFCGI) Server(org.eclipse.jetty.server.Server) LeakTrackingByteBufferPool(org.eclipse.jetty.io.LeakTrackingByteBufferPool) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) ServerConnector(org.eclipse.jetty.server.ServerConnector) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) HttpClient(org.eclipse.jetty.client.HttpClient) LeakTrackingConnectionPool(org.eclipse.jetty.client.LeakTrackingConnectionPool) HttpClientTransportOverFCGI(org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI)

Example 2 with HttpClientTransportOverFCGI

use of org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI in project jetty.project by eclipse.

the class ExternalFastCGIServerTest method testExternalFastCGIServer.

@Test
@Ignore("Relies on an external server")
public void testExternalFastCGIServer() throws Exception {
    // Assume a FastCGI server is listening on localhost:9000
    HttpClient client = new HttpClient(new HttpClientTransportOverFCGI("/var/www/php-fcgi"), null);
    client.start();
    ContentResponse response = client.newRequest("localhost", 9000).path("/index.php").timeout(5, TimeUnit.SECONDS).send();
    Assert.assertEquals(200, response.getStatus());
    Path responseFile = Paths.get(System.getProperty("java.io.tmpdir"), "fcgi_response.html");
    Files.write(responseFile, response.getContent(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
}
Also used : Path(java.nio.file.Path) ContentResponse(org.eclipse.jetty.client.api.ContentResponse) HttpClient(org.eclipse.jetty.client.HttpClient) HttpClientTransportOverFCGI(org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

HttpClient (org.eclipse.jetty.client.HttpClient)2 HttpClientTransportOverFCGI (org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI)2 Path (java.nio.file.Path)1 LeakTrackingConnectionPool (org.eclipse.jetty.client.LeakTrackingConnectionPool)1 Origin (org.eclipse.jetty.client.Origin)1 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)1 HttpDestinationOverFCGI (org.eclipse.jetty.fcgi.client.http.HttpDestinationOverFCGI)1 LeakTrackingByteBufferPool (org.eclipse.jetty.io.LeakTrackingByteBufferPool)1 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)1 Server (org.eclipse.jetty.server.Server)1 ServerConnector (org.eclipse.jetty.server.ServerConnector)1 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1