|
|
@ -154,10 +154,8 @@ public class RepositoryFilter implements Filter { |
|
|
|
static void sendError(int statusCode, HttpServletRequest req, |
|
|
|
static void sendError(int statusCode, HttpServletRequest req, |
|
|
|
HttpServletResponse rsp) throws IOException { |
|
|
|
HttpServletResponse rsp) throws IOException { |
|
|
|
String svc = req.getParameter("service"); |
|
|
|
String svc = req.getParameter("service"); |
|
|
|
String accept = req.getHeader(HDR_ACCEPT); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (svc != null && svc.startsWith("git-") && accept != null |
|
|
|
if (req.getRequestURI().endsWith("/info/refs") && isService(svc)) { |
|
|
|
&& accept.contains("application/x-" + svc + "-advertisement")) { |
|
|
|
|
|
|
|
// Smart HTTP service request, use an ERR response.
|
|
|
|
// Smart HTTP service request, use an ERR response.
|
|
|
|
rsp.setContentType("application/x-" + svc + "-advertisement"); |
|
|
|
rsp.setContentType("application/x-" + svc + "-advertisement"); |
|
|
|
|
|
|
|
|
|
|
@ -170,6 +168,7 @@ public class RepositoryFilter implements Filter { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String accept = req.getHeader(HDR_ACCEPT); |
|
|
|
if (accept != null && accept.contains(UploadPackServlet.RSP_TYPE)) { |
|
|
|
if (accept != null && accept.contains(UploadPackServlet.RSP_TYPE)) { |
|
|
|
// An upload-pack wants ACK or NAK, return ERR
|
|
|
|
// An upload-pack wants ACK or NAK, return ERR
|
|
|
|
// and the client will print this instead.
|
|
|
|
// and the client will print this instead.
|
|
|
@ -188,6 +187,10 @@ public class RepositoryFilter implements Filter { |
|
|
|
rsp.sendError(statusCode); |
|
|
|
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) { |
|
|
|
private static String translate(int statusCode) { |
|
|
|
switch (statusCode) { |
|
|
|
switch (statusCode) { |
|
|
|
case SC_NOT_FOUND: |
|
|
|
case SC_NOT_FOUND: |
|
|
|