From d3126d8345f15c28a794c217ae51517e2b242c06 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 14 Jan 2014 12:44:14 +0100 Subject: [PATCH] Small refactorings. --- .../client/http/HttpClientTransportOverFCGI.java | 14 ++++++++++++-- .../jetty/fcgi/client/http/HttpSenderOverFCGI.java | 3 ++- .../client/http/ExternalFastCGIServerTest.java | 6 ++++-- .../jetty/fcgi/server/HttpChannelOverFCGI.java | 2 ++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/fcgi-http-client-transport/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java b/fcgi-http-client-transport/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java index c54bf0eef9a..8275ef7c408 100644 --- a/fcgi-http-client-transport/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java +++ b/fcgi-http-client-transport/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java @@ -48,10 +48,20 @@ public class HttpClientTransportOverFCGI extends AbstractHttpClientTransport this.scriptRoot = scriptRoot; } + public boolean isMultiplexed() + { + return multiplexed; + } + + public String getScriptRoot() + { + return scriptRoot; + } + @Override public HttpDestination newHttpDestination(Origin origin) { - return multiplexed ? new MultiplexHttpDestinationOverFCGI(getHttpClient(), origin) + return isMultiplexed() ? new MultiplexHttpDestinationOverFCGI(getHttpClient(), origin) : new HttpDestinationOverFCGI(getHttpClient(), origin); } @@ -69,6 +79,6 @@ public class HttpClientTransportOverFCGI extends AbstractHttpClientTransport protected void customize(Request request, HttpFields fastCGIHeaders) { - fastCGIHeaders.put(FCGI.Headers.DOCUMENT_ROOT, scriptRoot); + fastCGIHeaders.put(FCGI.Headers.DOCUMENT_ROOT, getScriptRoot()); } } diff --git a/fcgi-http-client-transport/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpSenderOverFCGI.java b/fcgi-http-client-transport/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpSenderOverFCGI.java index bcce554fc81..f608824807a 100644 --- a/fcgi-http-client-transport/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpSenderOverFCGI.java +++ b/fcgi-http-client-transport/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpSenderOverFCGI.java @@ -14,6 +14,7 @@ import org.eclipse.jetty.fcgi.generator.Generator; import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; +import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Jetty; @@ -87,7 +88,7 @@ public class HttpSenderOverFCGI extends HttpSender } else { - Generator.Result noContentResult = generator.generateRequestContent(id, null, true, callback); + Generator.Result noContentResult = generator.generateRequestContent(id, BufferUtil.EMPTY_BUFFER, true, callback); getHttpChannel().flush(headersResult, noContentResult); } } diff --git a/fcgi-http-client-transport/src/test/java/org/eclipse/jetty/fcgi/client/http/ExternalFastCGIServerTest.java b/fcgi-http-client-transport/src/test/java/org/eclipse/jetty/fcgi/client/http/ExternalFastCGIServerTest.java index 496134e71a5..87f4512b39d 100644 --- a/fcgi-http-client-transport/src/test/java/org/eclipse/jetty/fcgi/client/http/ExternalFastCGIServerTest.java +++ b/fcgi-http-client-transport/src/test/java/org/eclipse/jetty/fcgi/client/http/ExternalFastCGIServerTest.java @@ -19,6 +19,7 @@ package org.eclipse.jetty.fcgi.client.http; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.concurrent.TimeUnit; @@ -35,7 +36,7 @@ public class ExternalFastCGIServerTest @Ignore("Relies on an external server") public void testExternalFastCGIServer() throws Exception { - // Assume a FastCGI server is listening on port 9000 + // Assume a FastCGI server is listening on localhost:9000 HttpClient client = new HttpClient(new HttpClientTransportOverFCGI("/var/www/php-fcgi"), null); client.start(); @@ -47,6 +48,7 @@ public class ExternalFastCGIServerTest Assert.assertEquals(200, response.getStatus()); - Files.write(Paths.get(System.getProperty("java.io.tmpdir"), "fcgi_response.html"), response.getContent(), StandardOpenOption.CREATE, StandardOpenOption.WRITE); + Path responseFile = Paths.get(System.getProperty("java.io.tmpdir"), "fcgi_response.html"); + Files.write(responseFile, response.getContent(), StandardOpenOption.CREATE, StandardOpenOption.WRITE); } } diff --git a/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java b/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java index 24c0b5b04cb..834c181d734 100644 --- a/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java +++ b/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java @@ -132,6 +132,7 @@ public class HttpChannelOverFCGI extends HttpChannel while (true) { State current = state.get(); + LOG.debug("Dispatching, state={}", current); switch (current) { case IDLE: @@ -166,6 +167,7 @@ public class HttpChannelOverFCGI extends HttpChannel while (true) { State current = state.get(); + LOG.debug("Running, state={}", current); switch (current) { case DISPATCH: