Factored common code.

This commit is contained in:
Simone Bordet 2014-05-20 21:48:04 +02:00
parent c4f7d38e86
commit 8bf0fee80b
1 changed files with 17 additions and 10 deletions

View File

@ -57,23 +57,20 @@ public class HttpTransportOverFCGI implements HttpTransport
{
if (lastContent)
{
Generator.Result headersResult = generator.generateResponseHeaders(request, info.getStatus(), info.getReason(),
info.getHttpFields(), Callback.Adapter.INSTANCE);
Generator.Result contentResult = generator.generateResponseContent(request, BufferUtil.EMPTY_BUFFER, lastContent, aborted, callback);
Generator.Result headersResult = generateResponseHeaders(info, Callback.Adapter.INSTANCE);
Generator.Result contentResult = generateResponseContent(BufferUtil.EMPTY_BUFFER, true, callback);
flusher.flush(headersResult, contentResult);
}
else
{
Generator.Result headersResult = generator.generateResponseHeaders(request, info.getStatus(), info.getReason(),
info.getHttpFields(), callback);
Generator.Result headersResult = generateResponseHeaders(info, callback);
flusher.flush(headersResult);
}
}
else
{
Generator.Result headersResult = generator.generateResponseHeaders(request, info.getStatus(), info.getReason(),
info.getHttpFields(), Callback.Adapter.INSTANCE);
Generator.Result contentResult = generator.generateResponseContent(request, content, lastContent, aborted, callback);
Generator.Result headersResult = generateResponseHeaders(info, Callback.Adapter.INSTANCE);
Generator.Result contentResult = generateResponseContent(content, lastContent, callback);
flusher.flush(headersResult, contentResult);
}
@ -88,7 +85,7 @@ public class HttpTransportOverFCGI implements HttpTransport
{
if (lastContent)
{
Generator.Result result = generator.generateResponseContent(request, BufferUtil.EMPTY_BUFFER, lastContent, aborted, callback);
Generator.Result result = generateResponseContent(BufferUtil.EMPTY_BUFFER, true, callback);
flusher.flush(result);
}
else
@ -99,7 +96,7 @@ public class HttpTransportOverFCGI implements HttpTransport
}
else
{
Generator.Result result = generator.generateResponseContent(request, content, lastContent, aborted, callback);
Generator.Result result = generateResponseContent(content, lastContent, callback);
flusher.flush(result);
}
@ -107,6 +104,16 @@ public class HttpTransportOverFCGI implements HttpTransport
flusher.shutdown();
}
protected Generator.Result generateResponseHeaders(HttpGenerator.ResponseInfo info, Callback callback)
{
return generator.generateResponseHeaders(request, info.getStatus(), info.getReason(), info.getHttpFields(), callback);
}
protected Generator.Result generateResponseContent(ByteBuffer buffer, boolean lastContent, Callback callback)
{
return generator.generateResponseContent(request, buffer, lastContent, aborted, callback);
}
@Override
public void abort()
{