Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.http.server/src')
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java20
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java15
2 files changed, 32 insertions, 3 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java
index 3e9c1fefac..ca6b749e75 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java
@@ -76,6 +76,7 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.InternalHttpServerGlue;
+import org.eclipse.jgit.transport.PacketLineOut;
import org.eclipse.jgit.transport.RefAdvertiser.PacketLineOutRefAdvertiser;
import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import org.eclipse.jgit.transport.UploadPack;
@@ -117,6 +118,25 @@ class UploadPackServlet extends HttpServlet {
up.setBiDirectionalPipe(false);
up.sendAdvertisedRefs(pck);
} finally {
+ // TODO(jonathantanmy): Move responsibility for closing the
+ // RevWalk to UploadPack, either by making it AutoCloseable
+ // or by making sendAdvertisedRefs clean up after itself.
+ up.getRevWalk().close();
+ }
+ }
+
+ @Override
+ protected void respond(HttpServletRequest req,
+ PacketLineOut pckOut, String serviceName) throws IOException,
+ ServiceNotEnabledException, ServiceNotAuthorizedException {
+ UploadPack up = (UploadPack) req.getAttribute(ATTRIBUTE_HANDLER);
+ try {
+ up.setBiDirectionalPipe(false);
+ up.sendAdvertisedRefs(new PacketLineOutRefAdvertiser(pckOut), serviceName);
+ } finally {
+ // TODO(jonathantanmy): Move responsibility for closing the
+ // RevWalk to UploadPack, either by making it AutoCloseable
+ // or by making sendAdvertisedRefs clean up after itself.
up.getRevWalk().close();
}
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java
index 30edc15166..a69fab0afd 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java
@@ -43,6 +43,8 @@
package org.eclipse.jgit.http.server.resolver;
+import java.util.Arrays;
+
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jgit.lib.Config;
@@ -73,9 +75,16 @@ public class DefaultUploadPackFactory implements
@Override
public UploadPack create(HttpServletRequest req, Repository db)
throws ServiceNotEnabledException, ServiceNotAuthorizedException {
- if (db.getConfig().get(ServiceConfig::new).enabled)
- return new UploadPack(db);
- else
+ if (db.getConfig().get(ServiceConfig::new).enabled) {
+ UploadPack up = new UploadPack(db);
+ String header = req.getHeader("Git-Protocol"); //$NON-NLS-1$
+ if (header != null) {
+ String[] params = header.split(":"); //$NON-NLS-1$
+ up.setExtraParameters(Arrays.asList(params));
+ }
+ return up;
+ } else {
throw new ServiceNotEnabledException();
+ }
}
}

Back to the top