public class GitSmartHttpTools extends Object
Modifier and Type | Field and Description |
---|---|
static String |
RECEIVE_PACK
Name of the git-receive-pack service.
|
static String |
RECEIVE_PACK_REQUEST_TYPE
Content type supplied by the client to the /git-receive-pack handler.
|
static String |
RECEIVE_PACK_RESULT_TYPE
Content type returned from the /git-receive-pack handler.
|
static String |
UPLOAD_PACK
Name of the git-upload-pack service.
|
static String |
UPLOAD_PACK_REQUEST_TYPE
Content type supplied by the client to the /git-upload-pack handler.
|
static String |
UPLOAD_PACK_RESULT_TYPE
Content type returned from the /git-upload-pack handler.
|
static List<String> |
VALID_SERVICES
Git service names accepted by the /info/refs?service= handler.
|
Modifier and Type | Method and Description |
---|---|
static String |
getResponseContentType(javax.servlet.http.HttpServletRequest req)
Get the response Content-Type a client expects for the request.
|
static boolean |
isGitClient(javax.servlet.http.HttpServletRequest req)
Check a request for Git-over-HTTP indicators.
|
static boolean |
isInfoRefs(javax.servlet.http.HttpServletRequest req)
Check if the HTTP request was for the /info/refs?service= Git handler.
|
static boolean |
isReceivePack(javax.servlet.http.HttpServletRequest req)
Check if the HTTP request was for the /git-receive-pack Git handler.
|
static boolean |
isUploadPack(javax.servlet.http.HttpServletRequest req)
Check if the HTTP request was for the /git-upload-pack Git handler.
|
static boolean |
isUploadPack(String pathOrUri)
Check if the HTTP request path ends with the /git-upload-pack handler.
|
static void |
sendError(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
int httpStatus)
Send an error to the Git client or browser.
|
static void |
sendError(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
int httpStatus,
String textForGit)
Send an error to the Git client or browser.
|
static String |
stripServiceSuffix(String path)
Strip the Git service suffix from a request path.
|
public static final String UPLOAD_PACK
public static final String RECEIVE_PACK
public static final String UPLOAD_PACK_REQUEST_TYPE
public static final String UPLOAD_PACK_RESULT_TYPE
public static final String RECEIVE_PACK_REQUEST_TYPE
public static final String RECEIVE_PACK_RESULT_TYPE
public static boolean isGitClient(javax.servlet.http.HttpServletRequest req)
req
- the current HTTP request that may have been made by Git.public static void sendError(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int httpStatus) throws IOException
Server implementors may use this method to send customized error messages to a Git protocol client using an HTTP 200 OK response with the error embedded in the payload. If the request was not issued by a Git client, an HTTP response code is returned instead.
req
- current request.res
- current response.httpStatus
- HTTP status code to set if the client is not a Git client.IOException
- the response cannot be sent.public static void sendError(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int httpStatus, String textForGit) throws IOException
Server implementors may use this method to send customized error messages to a Git protocol client using an HTTP 200 OK response with the error embedded in the payload. If the request was not issued by a Git client, an HTTP response code is returned instead.
This method may only be called before handing off the request to
UploadPack.upload(java.io.InputStream, OutputStream, OutputStream)
or
ReceivePack.receive(java.io.InputStream, OutputStream, OutputStream)
.
req
- current request.res
- current response.httpStatus
- HTTP status code to set if the client is not a Git client.textForGit
- plain text message to display on the user's console. This is
shown only if the client is likely to be a Git client. If null
or the empty string a default text is chosen based on the HTTP
response code.IOException
- the response cannot be sent.public static String getResponseContentType(javax.servlet.http.HttpServletRequest req)
This method should only be invoked if
isGitClient(HttpServletRequest)
is true.
req
- current request.IllegalArgumentException
- the request is not a Git client request. See
isGitClient(HttpServletRequest)
.public static String stripServiceSuffix(String path)
SuffixPipeline
handling
the request, so this method is rarely needed.path
- the path of the request.public static boolean isInfoRefs(javax.servlet.http.HttpServletRequest req)
req
- current request.public static boolean isUploadPack(String pathOrUri)
pathOrUri
- path or URI of the request.public static boolean isUploadPack(javax.servlet.http.HttpServletRequest req)
req
- current request.public static boolean isReceivePack(javax.servlet.http.HttpServletRequest req)
req
- current request.Copyright © 2015 Eclipse JGit Project. All rights reserved.