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) if (lastContent)
{ {
Generator.Result headersResult = generator.generateResponseHeaders(request, info.getStatus(), info.getReason(), Generator.Result headersResult = generateResponseHeaders(info, Callback.Adapter.INSTANCE);
info.getHttpFields(), Callback.Adapter.INSTANCE); Generator.Result contentResult = generateResponseContent(BufferUtil.EMPTY_BUFFER, true, callback);
Generator.Result contentResult = generator.generateResponseContent(request, BufferUtil.EMPTY_BUFFER, lastContent, aborted, callback);
flusher.flush(headersResult, contentResult); flusher.flush(headersResult, contentResult);
} }
else else
{ {
Generator.Result headersResult = generator.generateResponseHeaders(request, info.getStatus(), info.getReason(), Generator.Result headersResult = generateResponseHeaders(info, callback);
info.getHttpFields(), callback);
flusher.flush(headersResult); flusher.flush(headersResult);
} }
} }
else else
{ {
Generator.Result headersResult = generator.generateResponseHeaders(request, info.getStatus(), info.getReason(), Generator.Result headersResult = generateResponseHeaders(info, Callback.Adapter.INSTANCE);
info.getHttpFields(), Callback.Adapter.INSTANCE); Generator.Result contentResult = generateResponseContent(content, lastContent, callback);
Generator.Result contentResult = generator.generateResponseContent(request, content, lastContent, aborted, callback);
flusher.flush(headersResult, contentResult); flusher.flush(headersResult, contentResult);
} }
@ -88,7 +85,7 @@ public class HttpTransportOverFCGI implements HttpTransport
{ {
if (lastContent) 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); flusher.flush(result);
} }
else else
@ -99,7 +96,7 @@ public class HttpTransportOverFCGI implements HttpTransport
} }
else else
{ {
Generator.Result result = generator.generateResponseContent(request, content, lastContent, aborted, callback); Generator.Result result = generateResponseContent(content, lastContent, callback);
flusher.flush(result); flusher.flush(result);
} }
@ -107,6 +104,16 @@ public class HttpTransportOverFCGI implements HttpTransport
flusher.shutdown(); 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 @Override
public void abort() public void abort()
{ {