Package org.eclipse.jgit.util
Class HttpSupport
- java.lang.Object
-
- org.eclipse.jgit.util.HttpSupport
-
public class HttpSupport extends java.lang.Object
Extra utilities to support usage of HTTP.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ENCODING_GZIP
Thegzip
encoding value forHDR_ACCEPT_ENCODING
.static java.lang.String
HDR_ACCEPT
TheAccept
header.static java.lang.String
HDR_ACCEPT_ENCODING
TheAccept-Encoding
header.static java.lang.String
HDR_ACCEPT_RANGES
TheAccept-Ranges
header.static java.lang.String
HDR_AUTHORIZATION
TheAuthorization
header.static java.lang.String
HDR_CACHE_CONTROL
TheCache-Control
header.static java.lang.String
HDR_CONTENT_ENCODING
TheContent-Encoding
header.static java.lang.String
HDR_CONTENT_LENGTH
TheContent-Length
header.static java.lang.String
HDR_CONTENT_RANGE
TheContent-Range
header.static java.lang.String
HDR_CONTENT_TYPE
TheContent-Type
header.static java.lang.String
HDR_DATE
TheDate
header.static java.lang.String
HDR_ETAG
TheETag
header.static java.lang.String
HDR_EXPIRES
TheExpires
header.static java.lang.String
HDR_IF_MODIFIED_SINCE
TheIf-Modified-Since
header.static java.lang.String
HDR_IF_NONE_MATCH
TheIf-None-Match
header.static java.lang.String
HDR_IF_RANGE
TheIf-Range
header.static java.lang.String
HDR_LAST_MODIFIED
TheLast-Modified
header.static java.lang.String
HDR_PRAGMA
ThePragma
header.static java.lang.String
HDR_RANGE
TheRange
header.static java.lang.String
HDR_USER_AGENT
TheUser-Agent
header.static java.lang.String
HDR_WWW_AUTHENTICATE
TheWWW-Authenticate
header.static java.lang.String
METHOD_GET
TheGET
HTTP method.static java.lang.String
METHOD_POST
ThePOST
HTTP method.static java.lang.String
TEXT_PLAIN
The standardtext/plain
MIME type.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
encode(java.lang.StringBuilder urlstr, java.lang.String key)
URL encode a value string into an output buffer.static java.net.Proxy
proxyFor(java.net.ProxySelector proxySelector, java.net.URL u)
Determine the proxy server (if any) needed to obtain a URL.static int
response(java.net.HttpURLConnection c)
Get the HTTP response code from the request.static int
response(HttpConnection c)
Get the HTTP response code from the request.
-
-
-
Field Detail
-
METHOD_GET
public static final java.lang.String METHOD_GET
TheGET
HTTP method.- See Also:
- Constant Field Values
-
METHOD_POST
public static final java.lang.String METHOD_POST
ThePOST
HTTP method.- See Also:
- Constant Field Values
-
HDR_CACHE_CONTROL
public static final java.lang.String HDR_CACHE_CONTROL
TheCache-Control
header.- See Also:
- Constant Field Values
-
HDR_PRAGMA
public static final java.lang.String HDR_PRAGMA
ThePragma
header.- See Also:
- Constant Field Values
-
HDR_USER_AGENT
public static final java.lang.String HDR_USER_AGENT
TheUser-Agent
header.- See Also:
- Constant Field Values
-
HDR_DATE
public static final java.lang.String HDR_DATE
TheDate
header.- See Also:
- Constant Field Values
-
HDR_EXPIRES
public static final java.lang.String HDR_EXPIRES
TheExpires
header.- See Also:
- Constant Field Values
-
HDR_ETAG
public static final java.lang.String HDR_ETAG
TheETag
header.- See Also:
- Constant Field Values
-
HDR_IF_NONE_MATCH
public static final java.lang.String HDR_IF_NONE_MATCH
TheIf-None-Match
header.- See Also:
- Constant Field Values
-
HDR_LAST_MODIFIED
public static final java.lang.String HDR_LAST_MODIFIED
TheLast-Modified
header.- See Also:
- Constant Field Values
-
HDR_IF_MODIFIED_SINCE
public static final java.lang.String HDR_IF_MODIFIED_SINCE
TheIf-Modified-Since
header.- See Also:
- Constant Field Values
-
HDR_ACCEPT
public static final java.lang.String HDR_ACCEPT
TheAccept
header.- See Also:
- Constant Field Values
-
HDR_CONTENT_TYPE
public static final java.lang.String HDR_CONTENT_TYPE
TheContent-Type
header.- See Also:
- Constant Field Values
-
HDR_CONTENT_LENGTH
public static final java.lang.String HDR_CONTENT_LENGTH
TheContent-Length
header.- See Also:
- Constant Field Values
-
HDR_CONTENT_ENCODING
public static final java.lang.String HDR_CONTENT_ENCODING
TheContent-Encoding
header.- See Also:
- Constant Field Values
-
HDR_CONTENT_RANGE
public static final java.lang.String HDR_CONTENT_RANGE
TheContent-Range
header.- See Also:
- Constant Field Values
-
HDR_ACCEPT_RANGES
public static final java.lang.String HDR_ACCEPT_RANGES
TheAccept-Ranges
header.- See Also:
- Constant Field Values
-
HDR_IF_RANGE
public static final java.lang.String HDR_IF_RANGE
TheIf-Range
header.- See Also:
- Constant Field Values
-
HDR_RANGE
public static final java.lang.String HDR_RANGE
TheRange
header.- See Also:
- Constant Field Values
-
HDR_ACCEPT_ENCODING
public static final java.lang.String HDR_ACCEPT_ENCODING
TheAccept-Encoding
header.- See Also:
- Constant Field Values
-
ENCODING_GZIP
public static final java.lang.String ENCODING_GZIP
Thegzip
encoding value forHDR_ACCEPT_ENCODING
.- See Also:
- Constant Field Values
-
TEXT_PLAIN
public static final java.lang.String TEXT_PLAIN
The standardtext/plain
MIME type.- See Also:
- Constant Field Values
-
HDR_AUTHORIZATION
public static final java.lang.String HDR_AUTHORIZATION
TheAuthorization
header.- See Also:
- Constant Field Values
-
HDR_WWW_AUTHENTICATE
public static final java.lang.String HDR_WWW_AUTHENTICATE
TheWWW-Authenticate
header.- See Also:
- Constant Field Values
-
-
Method Detail
-
encode
public static void encode(java.lang.StringBuilder urlstr, java.lang.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 java.io.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
HttpConnection
for other defined constants. - Throws:
java.io.IOException
- communications error prevented obtaining the response code.- Since:
- 3.3
-
response
public static int response(java.net.HttpURLConnection c) throws java.io.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
HttpConnection
for other defined constants. - Throws:
java.io.IOException
- communications error prevented obtaining the response code.
-
proxyFor
public static java.net.Proxy proxyFor(java.net.ProxySelector proxySelector, java.net.URL u) throws java.net.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:
java.net.ConnectException
- the proxy could not be computed as the supplied URL could not be read. This failure should never occur.
-
-