From 9fec739702555e80bfe43f4839824ebfebf57a7e Mon Sep 17 00:00:00 2001 From: Max Haslbeck Date: Tue, 13 Aug 2024 13:16:53 +0200 Subject: 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 --- .../src/org/eclipse/jgit/http/server/GitSmartHttpTools.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 d2f0cd2731..bf3da4b5d0 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 @@ public class GitSmartHttpTools { 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); } -- cgit v1.2.3