org.eclipse.jgit.http.server
Class ClientVersionUtil

java.lang.Object
  extended by org.eclipse.jgit.http.server.ClientVersionUtil

public class ClientVersionUtil
extends Object

Parses Git client User-Agent strings.


Method Summary
static int compare(int[] a, int[] b)
          Compare two version strings for natural ordering.
static boolean hasChunkedEncodingRequestBug(int[] version, javax.servlet.http.HttpServletRequest request)
          Check if a Git client has the known chunked request body encoding bug.
static boolean hasPushStatusBug(int[] version)
          Check if a Git client has the known push status bug.
static int[] invalidVersion()
           
static int[] parseVersion(String version)
          Parse a Git client User-Agent header value.
static String toString(int[] ver)
          Convert a parsed version back to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

invalidVersion

public static int[] invalidVersion()
Returns:
maximum version array, indicating an invalid version of Git.

parseVersion

public static int[] parseVersion(String version)
Parse a Git client User-Agent header value.

Parameters:
version - git client version string, of the form "git/1.7.9".
Returns:
components of the version string. invalidVersion() if the version string cannot be parsed.

compare

public static int compare(int[] a,
                          int[] b)
Compare two version strings for natural ordering.

Parameters:
a - first parsed version string.
b - second parsed version string.
Returns:
<0 if a is before b; 0 if a equals b; >0 if a is after b.

toString

public static String toString(int[] ver)
Convert a parsed version back to a string.

Parameters:
ver - the parsed version array.
Returns:
a string, e.g. "1.6.6.0".

hasPushStatusBug

public static boolean hasPushStatusBug(int[] version)
Check if a Git client has the known push status bug.

These buggy clients do not display the status report from a failed push over HTTP.

Parameters:
version - parsed version of the Git client software.
Returns:
true if the bug is present.

hasChunkedEncodingRequestBug

public static boolean hasChunkedEncodingRequestBug(int[] version,
                                                   javax.servlet.http.HttpServletRequest request)
Check if a Git client has the known chunked request body encoding bug.

Git 1.7.5 contains a unique bug where chunked requests are malformed. This applies to both fetch and push.

Parameters:
version - parsed version of the Git client software.
request - incoming HTTP request.
Returns:
true if the client has the chunked encoding bug.


Copyright © 2013. All Rights Reserved.