summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.server/src
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2018-09-17 11:48:48 -0700
committerIvan Frade <ifrade@google.com>2018-10-12 13:59:06 -0700
commit6aca8899a5c02b3f6be7b9196cf5e935914476f0 (patch)
treebec623c7251d03297684721771d131434815cd30 /org.eclipse.jgit.http.server/src
parentb3adaf7741094c30f77ea933e7faa3977291d870 (diff)
downloadjgit-6aca8899a5c02b3f6be7b9196cf5e935914476f0.tar.gz
jgit-6aca8899a5c02b3f6be7b9196cf5e935914476f0.zip
Move first line parsing for v0/v1 pack negotiation out of UploadPack
In protocol v0/v1 pack negotiation, the first want line contains the options the client wants in effect. This parsing is done in UploadPack but it doesn't have any interaction with that class. Move the code to its own class and package, mark the current one as deprecated (it is public API) and add unit tests. Take the chance to move the parsing code from the constructor to a factory method, making the class a simple container of results. Change-Id: I1757f535dda78a4111a1c12c3a3b455a4b6f0c51 Signed-off-by: Ivan Frade <ifrade@google.com>
Diffstat (limited to 'org.eclipse.jgit.http.server/src')
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java
index b9ca12bf3d..ee4b32efb7 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java
@@ -63,6 +63,7 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.jgit.internal.transport.parser.FirstWant;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.transport.PacketLineIn;
import org.eclipse.jgit.transport.PacketLineOut;
@@ -246,9 +247,9 @@ public class GitSmartHttpTools {
// not have an UploadPack, or it might not have read any of the request.
// So, cheat and read the first line.
String line = new PacketLineIn(req.getInputStream()).readString();
- UploadPack.FirstLine parsed = new UploadPack.FirstLine(line);
- return (parsed.getOptions().contains(OPTION_SIDE_BAND)
- || parsed.getOptions().contains(OPTION_SIDE_BAND_64K));
+ FirstWant parsed = FirstWant.fromLine(line);
+ return (parsed.getCapabilities().contains(OPTION_SIDE_BAND)
+ || parsed.getCapabilities().contains(OPTION_SIDE_BAND_64K));
} catch (IOException e) {
// Probably the connection is closed and a subsequent write will fail, but
// try it just in case.