From 8bf0fee80b83538d66ddc7b9be496a9a1ffbd4a0 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 20 May 2014 21:48:04 +0200 Subject: [PATCH] Factored common code. --- .../fcgi/server/HttpTransportOverFCGI.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpTransportOverFCGI.java b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpTransportOverFCGI.java index 09555c7ee3c..a3070d9f19a 100644 --- a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpTransportOverFCGI.java +++ b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpTransportOverFCGI.java @@ -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() {