aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.server/src
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/AsIsFileFilter.java2
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java4
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java2
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoPacksServlet.java2
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java10
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/IsLocalFilter.java2
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java8
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java15
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java15
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java10
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java37
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/TextFileServlet.java4
-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/glue/ErrorServlet.java2
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexGroupFilter.java4
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java6
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/SuffixPipeline.java4
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/UrlPipeline.java8
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/AsIsFileService.java2
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java4
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java19
21 files changed, 109 insertions, 71 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/AsIsFileFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/AsIsFileFilter.java
index 7f826d4f27..9e9f25e611 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/AsIsFileFilter.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/AsIsFileFilter.java
@@ -66,7 +66,7 @@ import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
class AsIsFileFilter implements Filter {
private final AsIsFileService asIs;
- AsIsFileFilter(final AsIsFileService getAnyFile) {
+ AsIsFileFilter(AsIsFileService getAnyFile) {
this.asIs = getAnyFile;
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java
index 0d935fc98b..05510a05b0 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java
@@ -84,7 +84,7 @@ final class FileSender {
private long end;
- FileSender(final File path) throws FileNotFoundException {
+ FileSender(File path) throws FileNotFoundException {
this.path = path;
this.source = new RandomAccessFile(path, "r");
@@ -217,7 +217,7 @@ final class FileSender {
return true;
}
- private static Enumeration<String> getRange(final HttpServletRequest req) {
+ private static Enumeration<String> getRange(HttpServletRequest req) {
return req.getHeaders(HDR_RANGE);
}
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java
index ee23677caa..d0ea7b6dbc 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitServlet.java
@@ -183,7 +183,7 @@ public class GitServlet extends MetaServlet {
/** {@inheritDoc} */
@Override
- public void init(final ServletConfig config) throws ServletException {
+ public void init(ServletConfig config) throws ServletException {
gitFilter.init(new FilterConfig() {
@Override
public String getFilterName() {
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoPacksServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoPacksServlet.java
index 830e0611b7..52aaf51287 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoPacksServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoPacksServlet.java
@@ -67,7 +67,7 @@ class InfoPacksServlet extends HttpServlet {
sendPlainText(packList(req), req, rsp);
}
- private static String packList(final HttpServletRequest req) {
+ private static String packList(HttpServletRequest req) {
final StringBuilder out = new StringBuilder();
final ObjectDatabase db = getRepository(req).getObjectDatabase();
if (db instanceof ObjectDirectory) {
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java
index 4f70cf7004..0f4633b5e3 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java
@@ -44,18 +44,15 @@
package org.eclipse.jgit.http.server;
import static org.eclipse.jgit.http.server.ServletUtils.getRepository;
-import static org.eclipse.jgit.lib.RefDatabase.ALL;
import java.io.IOException;
import java.io.OutputStreamWriter;
-import java.util.Map;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.RefAdvertiser;
import org.eclipse.jgit.util.HttpSupport;
@@ -79,7 +76,7 @@ class InfoRefsServlet extends HttpServlet {
Constants.CHARSET)) {
final RefAdvertiser adv = new RefAdvertiser() {
@Override
- protected void writeOne(final CharSequence line)
+ protected void writeOne(CharSequence line)
throws IOException {
// Whoever decided that info/refs should use a different
// delimiter than the native git:// protocol shouldn't
@@ -94,10 +91,7 @@ class InfoRefsServlet extends HttpServlet {
};
adv.init(db);
adv.setDerefTags(true);
-
- Map<String, Ref> refs = db.getRefDatabase().getRefs(ALL);
- refs.remove(Constants.HEAD);
- adv.send(refs);
+ adv.send(db.getRefDatabase().getRefsByPrefix(Constants.R_REFS));
}
}
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/IsLocalFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/IsLocalFilter.java
index b0b831f3d6..b379983138 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/IsLocalFilter.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/IsLocalFilter.java
@@ -88,7 +88,7 @@ class IsLocalFilter implements Filter {
((HttpServletResponse) response).sendError(SC_FORBIDDEN);
}
- private static boolean isLocal(final Repository db) {
+ private static boolean isLocal(Repository db) {
return db.getObjectDatabase() instanceof ObjectDirectory;
}
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java
index 50dc68f99f..62f075c73c 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java
@@ -75,7 +75,7 @@ abstract class ObjectFileServlet extends HttpServlet {
}
@Override
- String etag(final FileSender sender) throws IOException {
+ String etag(FileSender sender) throws IOException {
return Long.toHexString(sender.getLastModified());
}
}
@@ -88,7 +88,7 @@ abstract class ObjectFileServlet extends HttpServlet {
}
@Override
- String etag(final FileSender sender) throws IOException {
+ String etag(FileSender sender) throws IOException {
return sender.getTailChecksum();
}
}
@@ -111,7 +111,7 @@ abstract class ObjectFileServlet extends HttpServlet {
private final String contentType;
- ObjectFileServlet(final String contentType) {
+ ObjectFileServlet(String contentType) {
this.contentType = contentType;
}
@@ -170,7 +170,7 @@ abstract class ObjectFileServlet extends HttpServlet {
}
}
- private static File objects(final HttpServletRequest req) {
+ private static File objects(HttpServletRequest req) {
final Repository db = getRepository(req);
return ((ObjectDirectory) db.getObjectDatabase()).getDirectory();
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java
index c89a5d762c..020be4f96f 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/RepositoryFilter.java
@@ -100,13 +100,13 @@ public class RepositoryFilter implements Filter {
* {@link org.eclipse.jgit.lib.Repository} instance for the
* current web request.
*/
- public RepositoryFilter(final RepositoryResolver<HttpServletRequest> resolver) {
+ public RepositoryFilter(RepositoryResolver<HttpServletRequest> resolver) {
this.resolver = resolver;
}
/** {@inheritDoc} */
@Override
- public void init(final FilterConfig config) throws ServletException {
+ public void init(FilterConfig config) throws ServletException {
context = config.getServletContext();
}
@@ -140,9 +140,9 @@ public class RepositoryFilter implements Filter {
return;
}
- final Repository db;
- try {
- db = resolver.open(req, name);
+ try (Repository db = resolver.open(req, name)) {
+ request.setAttribute(ATTRIBUTE_REPOSITORY, db);
+ chain.doFilter(request, response);
} catch (RepositoryNotFoundException e) {
sendError(req, res, SC_NOT_FOUND);
return;
@@ -155,13 +155,8 @@ public class RepositoryFilter implements Filter {
} catch (ServiceMayNotContinueException e) {
sendError(req, res, e.getStatusCode(), e.getMessage());
return;
- }
- try {
- request.setAttribute(ATTRIBUTE_REPOSITORY, db);
- chain.doFilter(request, response);
} finally {
request.removeAttribute(ATTRIBUTE_REPOSITORY);
- db.close();
}
}
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java
index f1ff547ea7..9601c8cafa 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java
@@ -90,7 +90,7 @@ public final class ServletUtils {
* the filter runs before the servlet.
* @see #ATTRIBUTE_REPOSITORY
*/
- public static Repository getRepository(final ServletRequest req) {
+ public static Repository getRepository(ServletRequest req) {
Repository db = (Repository) req.getAttribute(ATTRIBUTE_REPOSITORY);
if (db == null)
throw new IllegalStateException(HttpServerText.get().expectedRepositoryAttribute);
@@ -110,7 +110,7 @@ public final class ServletUtils {
* @throws IOException
* if an input or output exception occurred.
*/
- public static InputStream getInputStream(final HttpServletRequest req)
+ public static InputStream getInputStream(HttpServletRequest req)
throws IOException {
InputStream in = req.getInputStream();
final String enc = req.getHeader(HDR_CONTENT_ENCODING);
@@ -220,12 +220,9 @@ public final class ServletUtils {
public static void send(byte[] content, final HttpServletRequest req,
final HttpServletResponse rsp) throws IOException {
content = sendInit(content, req, rsp);
- final OutputStream out = rsp.getOutputStream();
- try {
+ try (OutputStream out = rsp.getOutputStream()) {
out.write(content);
out.flush();
- } finally {
- out.close();
}
}
@@ -241,7 +238,7 @@ public final class ServletUtils {
return content;
}
- static boolean acceptsGzipEncoding(final HttpServletRequest req) {
+ static boolean acceptsGzipEncoding(HttpServletRequest req) {
return acceptsGzipEncoding(req.getHeader(HDR_ACCEPT_ENCODING));
}
@@ -261,7 +258,7 @@ public final class ServletUtils {
return false;
}
- private static byte[] compress(final byte[] raw) throws IOException {
+ private static byte[] compress(byte[] raw) throws IOException {
final int maxLen = raw.length + 32;
final ByteArrayOutputStream out = new ByteArrayOutputStream(maxLen);
final GZIPOutputStream gz = new GZIPOutputStream(out);
@@ -271,7 +268,7 @@ public final class ServletUtils {
return out.toByteArray();
}
- private static String etag(final byte[] content) {
+ private static String etag(byte[] content) {
final MessageDigest md = Constants.newMessageDigest();
md.update(content);
return ObjectId.fromRaw(md.digest()).getName();
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java
index 4eb94a3a22..ad5e8d479e 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java
@@ -110,11 +110,8 @@ class SmartOutputStream extends TemporaryBuffer {
if (256 < out.length() && acceptsGzipEncoding(req)) {
TemporaryBuffer gzbuf = new TemporaryBuffer.Heap(LIMIT);
try {
- GZIPOutputStream gzip = new GZIPOutputStream(gzbuf);
- try {
+ try (GZIPOutputStream gzip = new GZIPOutputStream(gzbuf)) {
out.writeTo(gzip, null);
- } finally {
- gzip.close();
}
if (gzbuf.length() < out.length()) {
out = gzbuf;
@@ -131,12 +128,9 @@ class SmartOutputStream extends TemporaryBuffer {
// hardcoded LIMIT constant above assures us we wouldn't store
// more than 2 GiB of content in memory.
rsp.setContentLength((int) out.length());
- final OutputStream os = rsp.getOutputStream();
- try {
+ try (OutputStream os = rsp.getOutputStream()) {
out.writeTo(os, null);
os.flush();
- } finally {
- os.close();
}
}
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java
index 6417877e1b..195dff9613 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java
@@ -75,7 +75,7 @@ abstract class SmartServiceInfoRefs implements Filter {
private final Filter[] filters;
- SmartServiceInfoRefs(final String service, final List<Filter> filters) {
+ SmartServiceInfoRefs(String service, List<Filter> filters) {
this.svc = service;
this.filters = filters.toArray(new Filter[filters.size()]);
}
@@ -133,9 +133,7 @@ abstract class SmartServiceInfoRefs implements Filter {
res.setContentType(infoRefsResultType(svc));
final PacketLineOut out = new PacketLineOut(buf);
- out.writeString("# service=" + svc + "\n");
- out.end();
- advertise(req, new PacketLineOutRefAdvertiser(out));
+ respond(req, out, svc);
buf.close();
} catch (ServiceNotAuthorizedException e) {
res.sendError(SC_UNAUTHORIZED, e.getMessage());
@@ -178,6 +176,37 @@ abstract class SmartServiceInfoRefs implements Filter {
PacketLineOutRefAdvertiser pck) throws IOException,
ServiceNotEnabledException, ServiceNotAuthorizedException;
+ /**
+ * Writes the appropriate response to an info/refs request received by
+ * a smart service. In protocol v0, this starts with "#
+ * service=serviceName" followed by a flush packet, but this is not
+ * necessarily the case in other protocol versions.
+ * <p>
+ * The default implementation writes "# service=serviceName" and a
+ * flush packet, then calls {@link #advertise}. Subclasses should
+ * override this method if they support protocol versions other than
+ * protocol v0.
+ *
+ * @param req
+ * request
+ * @param pckOut
+ * destination of response
+ * @param serviceName
+ * service name to be written out in protocol v0; may or may
+ * not be used in other versions
+ * @throws IOException
+ * @throws ServiceNotEnabledException
+ * @throws ServiceNotAuthorizedException
+ */
+ protected void respond(HttpServletRequest req,
+ PacketLineOut pckOut, String serviceName)
+ throws IOException, ServiceNotEnabledException,
+ ServiceNotAuthorizedException {
+ pckOut.writeString("# service=" + svc + '\n'); //$NON-NLS-1$
+ pckOut.end();
+ advertise(req, new PacketLineOutRefAdvertiser(pckOut));
+ }
+
private class Chain implements FilterChain {
private int filterIdx;
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/TextFileServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/TextFileServlet.java
index 00851cfbe4..b2466d0e3e 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/TextFileServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/TextFileServlet.java
@@ -64,7 +64,7 @@ class TextFileServlet extends HttpServlet {
private final String fileName;
- TextFileServlet(final String name) {
+ TextFileServlet(String name) {
this.fileName = name;
}
@@ -80,7 +80,7 @@ class TextFileServlet extends HttpServlet {
}
}
- private byte[] read(final HttpServletRequest req) throws IOException {
+ private byte[] read(HttpServletRequest req) throws IOException {
final File gitdir = getRepository(req).getDirectory();
if (gitdir == null)
throw new FileNotFoundException(fileName);
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/glue/ErrorServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ErrorServlet.java
index 57fdddaf39..6f27b287f5 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ErrorServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ErrorServlet.java
@@ -64,7 +64,7 @@ public class ErrorServlet extends HttpServlet {
* @param status
* the HTTP status code to always send.
*/
- public ErrorServlet(final int status) {
+ public ErrorServlet(int status) {
this.status = status;
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexGroupFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexGroupFilter.java
index a3dc6c3702..f26ebc35f6 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexGroupFilter.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexGroupFilter.java
@@ -75,7 +75,7 @@ public class RegexGroupFilter implements Filter {
* @param groupIdx
* capture group number, 1 through the number of groups.
*/
- public RegexGroupFilter(final int groupIdx) {
+ public RegexGroupFilter(int groupIdx) {
if (groupIdx < 1)
throw new IllegalArgumentException(MessageFormat.format(
HttpServerText.get().invalidIndex, valueOf(groupIdx)));
@@ -108,7 +108,7 @@ public class RegexGroupFilter implements Filter {
valueOf(groupIdx + 1)));
}
- private static WrappedRequest[] groupsFor(final ServletRequest r) {
+ private static WrappedRequest[] groupsFor(ServletRequest r) {
return (WrappedRequest[]) r.getAttribute(MetaFilter.REGEX_GROUPS);
}
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java
index bf2d6dbb4d..010810508a 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java
@@ -87,11 +87,11 @@ class RegexPipeline extends UrlPipeline {
static class Binder extends ServletBinderImpl {
private final Pattern pattern;
- Binder(final String p) {
+ Binder(String p) {
pattern = Pattern.compile(p);
}
- Binder(final Pattern p) {
+ Binder(Pattern p) {
pattern = p;
}
@@ -110,7 +110,7 @@ class RegexPipeline extends UrlPipeline {
}
@Override
- boolean match(final HttpServletRequest req) {
+ boolean match(HttpServletRequest req) {
final String pathInfo = req.getPathInfo();
return pathInfo != null && pattern.matcher(pathInfo).matches();
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/SuffixPipeline.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/SuffixPipeline.java
index 6742c9f721..4fd99c6ef3 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/SuffixPipeline.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/SuffixPipeline.java
@@ -67,7 +67,7 @@ class SuffixPipeline extends UrlPipeline {
static class Binder extends ServletBinderImpl {
private final String suffix;
- Binder(final String suffix) {
+ Binder(String suffix) {
this.suffix = suffix;
}
@@ -89,7 +89,7 @@ class SuffixPipeline extends UrlPipeline {
}
@Override
- boolean match(final HttpServletRequest req) {
+ boolean match(HttpServletRequest req) {
final String pathInfo = req.getPathInfo();
return pathInfo != null && pathInfo.endsWith(suffix);
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/UrlPipeline.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/UrlPipeline.java
index 56e4e22889..c02399a23f 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/UrlPipeline.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/UrlPipeline.java
@@ -79,7 +79,7 @@ abstract class UrlPipeline {
/** Instance that must generate the response; never null. */
private final HttpServlet servlet;
- UrlPipeline(final Filter[] filters, final HttpServlet servlet) {
+ UrlPipeline(Filter[] filters, HttpServlet servlet) {
this.filters = filters;
this.servlet = servlet;
}
@@ -99,7 +99,7 @@ abstract class UrlPipeline {
* @throws ServletException
* a filter or servlet is unable to initialize.
*/
- void init(final ServletContext context, final Set<Object> inited)
+ void init(ServletContext context, Set<Object> inited)
throws ServletException {
for (Filter ref : filters)
initFilter(ref, context, inited);
@@ -165,7 +165,7 @@ abstract class UrlPipeline {
* destroyed a second time. Filters and servlets that are first
* destroyed by this pipeline will be added to this set.
*/
- void destroy(final Set<Object> destroyed) {
+ void destroy(Set<Object> destroyed) {
for (Filter ref : filters)
destroyFilter(ref, destroyed);
destroyServlet(servlet, destroyed);
@@ -230,7 +230,7 @@ abstract class UrlPipeline {
private int filterIdx;
- Chain(final Filter[] filters, final HttpServlet servlet) {
+ Chain(Filter[] filters, HttpServlet servlet) {
this.filters = filters;
this.servlet = servlet;
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/AsIsFileService.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/AsIsFileService.java
index 11ad5e0e1a..9a928b1e20 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/AsIsFileService.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/AsIsFileService.java
@@ -73,7 +73,7 @@ public class AsIsFileService {
private static class ServiceConfig {
final boolean enabled;
- ServiceConfig(final Config cfg) {
+ ServiceConfig(Config cfg) {
enabled = cfg.getBoolean("http", "getanyfile", true);
}
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java
index 95eb8d52d7..06a8f5effe 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java
@@ -74,7 +74,7 @@ public class DefaultReceivePackFactory implements
final boolean enabled;
- ServiceConfig(final Config cfg) {
+ ServiceConfig(Config cfg) {
set = cfg.getString("http", null, "receivepack") != null;
enabled = cfg.getBoolean("http", "receivepack", false);
}
@@ -82,7 +82,7 @@ public class DefaultReceivePackFactory implements
/** {@inheritDoc} */
@Override
- public ReceivePack create(final HttpServletRequest req, final Repository db)
+ public ReceivePack create(HttpServletRequest req, Repository db)
throws ServiceNotEnabledException, ServiceNotAuthorizedException {
final ServiceConfig cfg = db.getConfig().get(ServiceConfig::new);
String user = req.getRemoteUser();
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 f5afa1ecd0..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;
@@ -64,18 +66,25 @@ public class DefaultUploadPackFactory implements
private static class ServiceConfig {
final boolean enabled;
- ServiceConfig(final Config cfg) {
+ ServiceConfig(Config cfg) {
enabled = cfg.getBoolean("http", "uploadpack", true);
}
}
/** {@inheritDoc} */
@Override
- public UploadPack create(final HttpServletRequest req, final Repository db)
+ 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();
+ }
}
}