From 0b4751e805e3792403c5e3b39aa4f5555081991d Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Sat, 13 Aug 2016 16:56:20 +0900 Subject: [PATCH] LfsProtocolServlet: Always set the Content-Type header on response If the Content-Type is not set on error responses, the git-lfs client does not read the body which contains the error message, and instead just displays a generic error message. Also set the charset on the Content-Type header. Change-Id: I88e6f07f20b622a670e7c5063145dffb8b630aee Signed-off-by: David Pursehouse --- .../src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java index 984e4a962..bfd551d58 100644 --- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java +++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java @@ -83,7 +83,8 @@ public abstract class LfsProtocolServlet extends HttpServlet { private static final long serialVersionUID = 1L; - private static final String CONTENTTYPE_VND_GIT_LFS_JSON = "application/vnd.git-lfs+json"; //$NON-NLS-1$ + private static final String CONTENTTYPE_VND_GIT_LFS_JSON = + "application/vnd.git-lfs+json; charset=utf-8"; //$NON-NLS-1$ private Gson gson = createGson(); @@ -143,6 +144,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse res) LfsRequest request = gson.fromJson(r, LfsRequest.class); String path = req.getPathInfo(); + res.setContentType(CONTENTTYPE_VND_GIT_LFS_JSON); LargeFileRepository repo = null; try { repo = getLargeFileRepository(request, path); @@ -150,7 +152,6 @@ protected void doPost(HttpServletRequest req, HttpServletResponse res) res.setStatus(SC_SERVICE_UNAVAILABLE); } else { res.setStatus(SC_OK); - res.setContentType(CONTENTTYPE_VND_GIT_LFS_JSON); TransferHandler handler = TransferHandler .forOperation(request.operation, repo, request.objects); gson.toJson(handler.process(), w);