]> source.dussan.org Git - jgit.git/commitdiff
Do not set headers if response is already committed 96/1199396/2
authorMax Haslbeck <haslbeck@google.com>
Tue, 13 Aug 2024 11:16:53 +0000 (13:16 +0200)
committerHaslbeck Max <haslbeck@google.com>
Tue, 27 Aug 2024 07:25:33 +0000 (07:25 +0000)
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>
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java

index d2f0cd2731d13541b619bf564ba6abe870ada1dc..bf3da4b5d081b228cffaefba339a136e16a0068b 100644 (file)
@@ -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);
                }