diff options
author | Shawn Pearce <spearce@spearce.org> | 2015-04-30 12:43:46 -0700 |
---|---|---|
committer | Shawn Pearce <spearce@spearce.org> | 2015-04-30 14:40:35 -0700 |
commit | 4a984e20332a765a81cadeaa4875b228ebf290fb (patch) | |
tree | 68591da210bd0d795e9e7da3b9ad790d26261840 /org.eclipse.jgit.http.server | |
parent | 7e0ebb8e29a1bc73ead72bc00569f06169079a26 (diff) | |
download | jgit-4a984e20332a765a81cadeaa4875b228ebf290fb.tar.gz jgit-4a984e20332a765a81cadeaa4875b228ebf290fb.zip |
Support agent= capability in wire protocol
Since git-core ff5effd (v1.7.12.1) the native wire protocol transmits
the server and client implementation and version strings using
capability "agent=git/1.7.12.1" or similar.
Support this in JGit and hang the implementation data off UploadPack
and ReceivePack. On HTTP transports default to the User-Agent HTTP
header until the client overrides this with the optional capability
string in the first line.
Extract the user agent string into a UserAgent class under transport
where it can be specified to a different value if the application's
build process has broken the Implementation-Version header in the
JGit package.
Change-Id: Icfc6524d84a787386d1786310b421b2f92ae9e65
Diffstat (limited to 'org.eclipse.jgit.http.server')
-rw-r--r-- | org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java | 4 | ||||
-rw-r--r-- | org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java index d1c258047b..a8e312d3f0 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java @@ -76,6 +76,7 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jgit.errors.UnpackException; import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.transport.InternalHttpServerGlue; import org.eclipse.jgit.transport.ReceivePack; import org.eclipse.jgit.transport.RefAdvertiser.PacketLineOutRefAdvertiser; import org.eclipse.jgit.transport.resolver.ReceivePackFactory; @@ -100,6 +101,9 @@ class ReceivePackServlet extends HttpServlet { throws IOException, ServiceNotEnabledException, ServiceNotAuthorizedException { ReceivePack rp = receivePackFactory.create(req, db); + InternalHttpServerGlue.setPeerUserAgent( + rp, + req.getHeader(HDR_USER_AGENT)); req.setAttribute(ATTRIBUTE_HANDLER, rp); } 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 c5272b55eb..7aefcbd809 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 @@ -74,6 +74,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.transport.InternalHttpServerGlue; import org.eclipse.jgit.transport.RefAdvertiser.PacketLineOutRefAdvertiser; import org.eclipse.jgit.transport.UploadPack; import org.eclipse.jgit.transport.UploadPackInternalServerErrorException; @@ -100,6 +101,9 @@ class UploadPackServlet extends HttpServlet { throws IOException, ServiceNotEnabledException, ServiceNotAuthorizedException { UploadPack up = uploadPackFactory.create(req, db); + InternalHttpServerGlue.setPeerUserAgent( + up, + req.getHeader(HDR_USER_AGENT)); req.setAttribute(ATTRIBUTE_HANDLER, up); } |