Small refactorings.

This commit is contained in:
Simone Bordet 2014-01-14 12:44:14 +01:00
parent 9dcde09cba
commit d3126d8345
4 changed files with 20 additions and 5 deletions

View File

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

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -132,6 +132,7 @@ public class HttpChannelOverFCGI extends HttpChannel<ByteBuffer>
while (true)
{
State current = state.get();
LOG.debug("Dispatching, state={}", current);
switch (current)
{
case IDLE:
@ -166,6 +167,7 @@ public class HttpChannelOverFCGI extends HttpChannel<ByteBuffer>
while (true)
{
State current = state.get();
LOG.debug("Running, state={}", current);
switch (current)
{
case DISPATCH: