summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.server/src/org/eclipse
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2011-05-04 14:55:53 -0700
committerShawn O. Pearce <spearce@spearce.org>2011-05-04 14:58:33 -0700
commitde16d5e8f98610e253d46e25a39ee4edfca23b92 (patch)
treeeb6701c2d6a6542c4a38ead3a8926965dbb1f8a0 /org.eclipse.jgit.http.server/src/org/eclipse
parente2413ce2f65b965a706621b50865cfda8c395c4f (diff)
downloadjgit-de16d5e8f98610e253d46e25a39ee4edfca23b92.tar.gz
jgit-de16d5e8f98610e253d46e25a39ee4edfca23b92.zip
Fix error handling in RepositoryFilter
The filter did not correctly match smart HTTP client requests, so it always fell back on HTTP status codes for errors. This usually causes a smart client to retry a dumb request, which is not what the server wants. Change-Id: I42592378dc42fbe308ef30a2923786c690f668a9 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.http.server/src/org/eclipse')
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java
index 3e0a572564..1462593858 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java
@@ -154,10 +154,8 @@ public class RepositoryFilter implements Filter {
static void sendError(int statusCode, HttpServletRequest req,
HttpServletResponse rsp) throws IOException {
String svc = req.getParameter("service");
- String accept = req.getHeader(HDR_ACCEPT);
- if (svc != null && svc.startsWith("git-") && accept != null
- && accept.contains("application/x-" + svc + "-advertisement")) {
+ if (req.getRequestURI().endsWith("/info/refs") && isService(svc)) {
// Smart HTTP service request, use an ERR response.
rsp.setContentType("application/x-" + svc + "-advertisement");
@@ -170,6 +168,7 @@ public class RepositoryFilter implements Filter {
return;
}
+ String accept = req.getHeader(HDR_ACCEPT);
if (accept != null && accept.contains(UploadPackServlet.RSP_TYPE)) {
// An upload-pack wants ACK or NAK, return ERR
// and the client will print this instead.
@@ -188,6 +187,10 @@ public class RepositoryFilter implements Filter {
rsp.sendError(statusCode);
}
+ private static boolean isService(String svc) {
+ return "git-upload-pack".equals(svc) || "git-receive-pack".equals(svc);
+ }
+
private static String translate(int statusCode) {
switch (statusCode) {
case SC_NOT_FOUND: