Merge branch 'stable-2.15'
* stable-2.15:
Allow git-upload-pack on Git/SmartHTTP
Change-Id: I0f0c253916ef3a9196cc523adf3b188778c70f74
diff --git a/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java b/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java
index 8abe38f..c651474 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java
@@ -34,6 +34,7 @@
@Singleton
class ReadOnly extends AllRequestFilter implements CommitValidationListener {
+ private static final String GIT_UPLOAD_PACK_PROTOCOL = "/git-upload-pack";
private final ReadOnlyConfig config;
@Inject
@@ -52,7 +53,10 @@
throws IOException, ServletException {
if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse)) {
String method = ((HttpServletRequest) request).getMethod();
- if (method == "POST" || method == "PUT" || method == "DELETE") {
+ String uri = ((HttpServletRequest) request).getRequestURI();
+ if ((method == "POST" && !uri.endsWith(GIT_UPLOAD_PACK_PROTOCOL))
+ || method == "PUT"
+ || method == "DELETE") {
((HttpServletResponse) response).sendError(SC_SERVICE_UNAVAILABLE, config.message());
return;
}