Do not set headers if response is already committed This fixes issues when the response headers were already set and sent to the client. In all other cases this is a no-op. Change-Id: Ifb429e78f721cc514bb6eb1a3ef3412425cd2f1c Signed-off-by: Max Haslbeck <haslbeck@google.com>
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java index d2f0cd2..bf3da4b 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java
@@ -255,9 +255,11 @@ private static void writePacket(PacketLineOut pckOut, String textForGit) private static void send(HttpServletRequest req, HttpServletResponse res, String type, byte[] buf, int httpStatus) throws IOException { ServletUtils.consumeRequestBody(req); - res.setStatus(httpStatus); - res.setContentType(type); - res.setContentLength(buf.length); + if (!res.isCommitted()) { + res.setStatus(httpStatus); + res.setContentType(type); + res.setContentLength(buf.length); + } try (OutputStream os = res.getOutputStream()) { os.write(buf); }