diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/ContainerAuthFilter.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/ContainerAuthFilter.java index 97fffd76cd..c0e3f424ab 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/ContainerAuthFilter.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/ContainerAuthFilter.java @@ -49,7 +49,7 @@ import javax.servlet.http.HttpServletResponseWrapper; *
* This filter should only be configured to run, when authentication is
* configured to trust container authentication. This filter is intended only to
- * protect the {@link GitOverHttpFilter} and its handled URLs, which provide remote
+ * protect the {@link GitOverHttpServlet} and its handled URLs, which provide remote
* repository access over HTTP.
*/
@Singleton
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitOverHttpModule.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitOverHttpModule.java
index 63b473718f..6fd94c94cb 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitOverHttpModule.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitOverHttpModule.java
@@ -38,8 +38,8 @@ public class GitOverHttpModule extends ServletModule {
authFilter = ProjectDigestFilter.class;
}
- String git = GitOverHttpFilter.URL_REGEX;
+ String git = GitOverHttpServlet.URL_REGEX;
filterRegex(git).through(authFilter);
- filterRegex(git).through(GitOverHttpFilter.class);
+ serveRegex(git).with(GitOverHttpServlet.class);
}
}
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitOverHttpFilter.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitOverHttpServlet.java
similarity index 87%
rename from gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitOverHttpFilter.java
rename to gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitOverHttpServlet.java
index 47b59746fc..145891f61e 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitOverHttpFilter.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitOverHttpServlet.java
@@ -37,7 +37,7 @@ import com.google.inject.TypeLiteral;
import com.google.inject.name.Named;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
-import org.eclipse.jgit.http.server.GitFilter;
+import org.eclipse.jgit.http.server.GitServlet;
import org.eclipse.jgit.http.server.GitSmartHttpTools;
import org.eclipse.jgit.http.server.ServletUtils;
import org.eclipse.jgit.http.server.resolver.AsIsFileService;
@@ -65,20 +65,27 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
/** Serves Git repositories over HTTP. */
@Singleton
-public class GitOverHttpFilter extends GitFilter {
+public class GitOverHttpServlet extends GitServlet {
private static final long serialVersionUID = 1L;
private static final String ATT_CONTROL = ProjectControl.class.getName();
private static final String ATT_RC = ReceiveCommits.class.getName();
private static final String ID_CACHE = "adv_bases";
- public static final String URL_REGEX =
- "^/.*/(?:info/refs|git-upload-pack|git-receive-pack)$";
+ public static final String URL_REGEX;
+ static {
+ StringBuilder url = new StringBuilder();
+ url.append("^(?:/p/|/)(.*/(?:info/refs");
+ for (String name : GitSmartHttpTools.VALID_SERVICES) {
+ url.append('|').append(name);
+ }
+ url.append("))$");
+ URL_REGEX = url.toString();
+ }
static class Module extends AbstractModule {
@Override
@@ -102,7 +109,7 @@ public class GitOverHttpFilter extends GitFilter {
}
@Inject
- GitOverHttpFilter(Resolver resolver,
+ GitOverHttpServlet(Resolver resolver,
UploadFactory upload, UploadFilter uploadFilter,
ReceiveFactory receive, ReceiveFilter receiveFilter) {
setRepositoryResolver(resolver);
@@ -115,29 +122,6 @@ public class GitOverHttpFilter extends GitFilter {
addReceivePackFilter(receiveFilter);
}
-
- @Override
- public void doFilter(ServletRequest request, ServletResponse response,
- FilterChain chain) throws IOException, ServletException {
- // JGit doesn't handle parsing the request as-is. It assumes
- // the relevant data is available in getPathInfo(), but this
- // isn't true in GuiceFilter. Massage the request for JGit.
- final HttpServletRequest req = (HttpServletRequest) request;
- HttpServletRequestWrapper wrapped = new HttpServletRequestWrapper(req) {
- @Override
- public String getPathInfo() {
- return req.getRequestURI().substring(1);
- }
-
- @Override
- public String getServletPath() {
- return "/";
- }
- };
- super.doFilter(wrapped, response, chain);
- }
-
-
static class Resolver implements RepositoryResolver
* The current HTTP request is authenticated by looking up the username from the
* Authorization header and checking the digest response against the stored
- * password. This filter is intended only to protect the {@link GitOverHttpFilter}
+ * password. This filter is intended only to protect the {@link GitOverHttpServlet}
* and its handled URLs, which provide remote repository access over HTTP.
*
* @see RFC 2617
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/WebModule.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/WebModule.java
index 3ead2325c8..611d3c62a0 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/WebModule.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/WebModule.java
@@ -119,7 +119,7 @@ public class WebModule extends FactoryModule {
install(new UrlModule());
install(new UiRpcModule());
install(new GerritRequestModule());
- install(new GitOverHttpFilter.Module());
+ install(new GitOverHttpServlet.Module());
bind(GitWebConfig.class).toInstance(gitWebConfig);
if (gitWebConfig.getGitwebCGI() != null) {
diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/Daemon.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/Daemon.java
index 73ddd50b57..624768d05d 100644
--- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/Daemon.java
+++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/Daemon.java
@@ -252,8 +252,8 @@ public class Daemon extends SiteProgram {
final List