Small refactorings.
This commit is contained in:
parent
9dcde09cba
commit
d3126d8345
|
@ -48,10 +48,20 @@ public class HttpClientTransportOverFCGI extends AbstractHttpClientTransport
|
||||||
this.scriptRoot = scriptRoot;
|
this.scriptRoot = scriptRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMultiplexed()
|
||||||
|
{
|
||||||
|
return multiplexed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScriptRoot()
|
||||||
|
{
|
||||||
|
return scriptRoot;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpDestination newHttpDestination(Origin origin)
|
public HttpDestination newHttpDestination(Origin origin)
|
||||||
{
|
{
|
||||||
return multiplexed ? new MultiplexHttpDestinationOverFCGI(getHttpClient(), origin)
|
return isMultiplexed() ? new MultiplexHttpDestinationOverFCGI(getHttpClient(), origin)
|
||||||
: new HttpDestinationOverFCGI(getHttpClient(), origin);
|
: new HttpDestinationOverFCGI(getHttpClient(), origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +79,6 @@ public class HttpClientTransportOverFCGI extends AbstractHttpClientTransport
|
||||||
|
|
||||||
protected void customize(Request request, HttpFields fastCGIHeaders)
|
protected void customize(Request request, HttpFields fastCGIHeaders)
|
||||||
{
|
{
|
||||||
fastCGIHeaders.put(FCGI.Headers.DOCUMENT_ROOT, scriptRoot);
|
fastCGIHeaders.put(FCGI.Headers.DOCUMENT_ROOT, getScriptRoot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.jetty.fcgi.generator.Generator;
|
||||||
import org.eclipse.jetty.http.HttpField;
|
import org.eclipse.jetty.http.HttpField;
|
||||||
import org.eclipse.jetty.http.HttpFields;
|
import org.eclipse.jetty.http.HttpFields;
|
||||||
import org.eclipse.jetty.http.HttpHeader;
|
import org.eclipse.jetty.http.HttpHeader;
|
||||||
|
import org.eclipse.jetty.util.BufferUtil;
|
||||||
import org.eclipse.jetty.util.Callback;
|
import org.eclipse.jetty.util.Callback;
|
||||||
import org.eclipse.jetty.util.Jetty;
|
import org.eclipse.jetty.util.Jetty;
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ public class HttpSenderOverFCGI extends HttpSender
|
||||||
}
|
}
|
||||||
else
|
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);
|
getHttpChannel().flush(headersResult, noContentResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.eclipse.jetty.fcgi.client.http;
|
package org.eclipse.jetty.fcgi.client.http;
|
||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -35,7 +36,7 @@ public class ExternalFastCGIServerTest
|
||||||
@Ignore("Relies on an external server")
|
@Ignore("Relies on an external server")
|
||||||
public void testExternalFastCGIServer() throws Exception
|
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);
|
HttpClient client = new HttpClient(new HttpClientTransportOverFCGI("/var/www/php-fcgi"), null);
|
||||||
client.start();
|
client.start();
|
||||||
|
@ -47,6 +48,7 @@ public class ExternalFastCGIServerTest
|
||||||
|
|
||||||
Assert.assertEquals(200, response.getStatus());
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,6 +132,7 @@ public class HttpChannelOverFCGI extends HttpChannel<ByteBuffer>
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
State current = state.get();
|
State current = state.get();
|
||||||
|
LOG.debug("Dispatching, state={}", current);
|
||||||
switch (current)
|
switch (current)
|
||||||
{
|
{
|
||||||
case IDLE:
|
case IDLE:
|
||||||
|
@ -166,6 +167,7 @@ public class HttpChannelOverFCGI extends HttpChannel<ByteBuffer>
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
State current = state.get();
|
State current = state.get();
|
||||||
|
LOG.debug("Running, state={}", current);
|
||||||
switch (current)
|
switch (current)
|
||||||
{
|
{
|
||||||
case DISPATCH:
|
case DISPATCH:
|
||||||
|
|
Loading…
Reference in New Issue