diff options
author | Max Haslbeck <haslbeck@google.com> | 2024-08-13 13:16:53 +0200 |
---|---|---|
committer | Haslbeck Max <haslbeck@google.com> | 2024-08-27 07:25:33 +0000 |
commit | 9fec739702555e80bfe43f4839824ebfebf57a7e (patch) | |
tree | bbd927fde735dc14ea0b47afb0f50b16f60a5a06 | |
parent | a78e6eaef63754902f46dffe657a783403c44bfe (diff) | |
download | jgit-9fec739702555e80bfe43f4839824ebfebf57a7e.tar.gz jgit-9fec739702555e80bfe43f4839824ebfebf57a7e.zip |
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>
-rw-r--r-- | org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java | 8 |
1 files 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); } |