Allow git-upload-pack on Git/SmartHTTP

The HTTP POST are typically modifications with the
execption of the SmartHTTP protocol where they are used
for the git-upload-pack verb which is associated with
git fetch and clone operations.

Git fetch and clone should be allowed even when the
entire instance is read-only.

Change-Id: Ia7b816d010550bf0193450f3587e6172d4934afb
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;
       }