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();
}
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);
}
Aggregations