Package org.eclipse.jgit.util
Class HttpSupport
- java.lang.Object
-
- org.eclipse.jgit.util.HttpSupport
-
public class HttpSupport extends Object
Extra utilities to support usage of HTTP.
-
-
Field Summary
Fields Modifier and Type Field Description static StringENCODING_GZIPThegzipencoding value forHDR_ACCEPT_ENCODING.static StringHDR_ACCEPTTheAcceptheader.static StringHDR_ACCEPT_ENCODINGTheAccept-Encodingheader.static StringHDR_ACCEPT_RANGESTheAccept-Rangesheader.static StringHDR_AUTHORIZATIONTheAuthorizationheader.static StringHDR_CACHE_CONTROLTheCache-Controlheader.static StringHDR_CONTENT_ENCODINGTheContent-Encodingheader.static StringHDR_CONTENT_LENGTHTheContent-Lengthheader.static StringHDR_CONTENT_RANGETheContent-Rangeheader.static StringHDR_CONTENT_TYPETheContent-Typeheader.static StringHDR_DATETheDateheader.static StringHDR_ETAGTheETagheader.static StringHDR_EXPIRESTheExpiresheader.static StringHDR_IF_MODIFIED_SINCETheIf-Modified-Sinceheader.static StringHDR_IF_NONE_MATCHTheIf-None-Matchheader.static StringHDR_IF_RANGETheIf-Rangeheader.static StringHDR_LAST_MODIFIEDTheLast-Modifiedheader.static StringHDR_PRAGMAThePragmaheader.static StringHDR_RANGETheRangeheader.static StringHDR_USER_AGENTTheUser-Agentheader.static StringHDR_WWW_AUTHENTICATETheWWW-Authenticateheader.static StringMETHOD_GETTheGETHTTP method.static StringMETHOD_POSTThePOSTHTTP method.static StringTEXT_PLAINThe standardtext/plainMIME type.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidencode(StringBuilder urlstr, String key)URL encode a value string into an output buffer.static ProxyproxyFor(ProxySelector proxySelector, URL u)Determine the proxy server (if any) needed to obtain a URL.static intresponse(HttpURLConnection c)Get the HTTP response code from the request.static intresponse(HttpConnection c)Get the HTTP response code from the request.
-
-
-
Field Detail
-
METHOD_GET
public static final String METHOD_GET
TheGETHTTP method.- See Also:
- Constant Field Values
-
METHOD_POST
public static final String METHOD_POST
ThePOSTHTTP method.- See Also:
- Constant Field Values
-
HDR_CACHE_CONTROL
public static final String HDR_CACHE_CONTROL
TheCache-Controlheader.- See Also:
- Constant Field Values
-
HDR_PRAGMA
public static final String HDR_PRAGMA
ThePragmaheader.- See Also:
- Constant Field Values
-
HDR_USER_AGENT
public static final String HDR_USER_AGENT
TheUser-Agentheader.- See Also:
- Constant Field Values
-
HDR_DATE
public static final String HDR_DATE
TheDateheader.- See Also:
- Constant Field Values
-
HDR_EXPIRES
public static final String HDR_EXPIRES
TheExpiresheader.- See Also:
- Constant Field Values
-
HDR_ETAG
public static final String HDR_ETAG
TheETagheader.- See Also:
- Constant Field Values
-
HDR_IF_NONE_MATCH
public static final String HDR_IF_NONE_MATCH
TheIf-None-Matchheader.- See Also:
- Constant Field Values
-
HDR_LAST_MODIFIED
public static final String HDR_LAST_MODIFIED
TheLast-Modifiedheader.- See Also:
- Constant Field Values
-
HDR_IF_MODIFIED_SINCE
public static final String HDR_IF_MODIFIED_SINCE
TheIf-Modified-Sinceheader.- See Also:
- Constant Field Values
-
HDR_ACCEPT
public static final String HDR_ACCEPT
TheAcceptheader.- See Also:
- Constant Field Values
-
HDR_CONTENT_TYPE
public static final String HDR_CONTENT_TYPE
TheContent-Typeheader.- See Also:
- Constant Field Values
-
HDR_CONTENT_LENGTH
public static final String HDR_CONTENT_LENGTH
TheContent-Lengthheader.- See Also:
- Constant Field Values
-
HDR_CONTENT_ENCODING
public static final String HDR_CONTENT_ENCODING
TheContent-Encodingheader.- See Also:
- Constant Field Values
-
HDR_CONTENT_RANGE
public static final String HDR_CONTENT_RANGE
TheContent-Rangeheader.- See Also:
- Constant Field Values
-
HDR_ACCEPT_RANGES
public static final String HDR_ACCEPT_RANGES
TheAccept-Rangesheader.- See Also:
- Constant Field Values
-
HDR_IF_RANGE
public static final String HDR_IF_RANGE
TheIf-Rangeheader.- See Also:
- Constant Field Values
-
HDR_RANGE
public static final String HDR_RANGE
TheRangeheader.- See Also:
- Constant Field Values
-
HDR_ACCEPT_ENCODING
public static final String HDR_ACCEPT_ENCODING
TheAccept-Encodingheader.- See Also:
- Constant Field Values
-
ENCODING_GZIP
public static final String ENCODING_GZIP
Thegzipencoding value forHDR_ACCEPT_ENCODING.- See Also:
- Constant Field Values
-
TEXT_PLAIN
public static final String TEXT_PLAIN
The standardtext/plainMIME type.- See Also:
- Constant Field Values
-
HDR_AUTHORIZATION
public static final String HDR_AUTHORIZATION
TheAuthorizationheader.- See Also:
- Constant Field Values
-
HDR_WWW_AUTHENTICATE
public static final String HDR_WWW_AUTHENTICATE
TheWWW-Authenticateheader.- See Also:
- Constant Field Values
-
-
Method Detail
-
encode
public static void encode(StringBuilder urlstr, String key)
URL encode a value string into an output buffer.- Parameters:
urlstr- the output buffer.key- value which must be encoded to protected special characters.
-
response
public static int response(HttpConnection c) throws IOException
Get the HTTP response code from the request.Roughly the same as
c.getResponseCode()but the ConnectException is translated to be more understandable.- Parameters:
c- connection the code should be obtained from.- Returns:
- r HTTP status code, usually 200 to indicate success. See
HttpConnectionfor other defined constants. - Throws:
IOException- communications error prevented obtaining the response code.- Since:
- 3.3
-
response
public static int response(HttpURLConnection c) throws IOException
Get the HTTP response code from the request.Roughly the same as
c.getResponseCode()but the ConnectException is translated to be more understandable.- Parameters:
c- connection the code should be obtained from.- Returns:
- r HTTP status code, usually 200 to indicate success. See
HttpConnectionfor other defined constants. - Throws:
IOException- communications error prevented obtaining the response code.
-
proxyFor
public static Proxy proxyFor(ProxySelector proxySelector, URL u) throws ConnectException
Determine the proxy server (if any) needed to obtain a URL.- Parameters:
proxySelector- proxy support for the caller.u- location of the server caller wants to talk to.- Returns:
- proxy to communicate with the supplied URL.
- Throws:
ConnectException- the proxy could not be computed as the supplied URL could not be read. This failure should never occur.
-
-