Package org.eclipse.jgit.util
Class HttpSupport
java.lang.Object
org.eclipse.jgit.util.HttpSupport
Extra utilities to support usage of HTTP.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThegzipencoding value forHDR_ACCEPT_ENCODING.static final StringThex-gzipencoding value forHDR_ACCEPT_ENCODING.static final StringTheAcceptheader.static final StringTheAccept-Encodingheader.static final StringTheAccept-Rangesheader.static final StringTheAuthorizationheader.static final StringTheCache-Controlheader.static final StringTheContent-Encodingheader.static final StringTheContent-Lengthheader.static final StringTheContent-Rangeheader.static final StringTheContent-Typeheader.static final StringTheCookieheader.static final StringTheDateheader.static final StringTheETagheader.static final StringTheExpiresheader.static final StringTheIf-Modified-Sinceheader.static final StringTheIf-None-Matchheader.static final StringTheIf-Rangeheader.static final StringTheLast-Modifiedheader.static final StringTheLocationheader.static final StringThePragmaheader.static final StringTheRangeheader.static final StringTheServerheader.static final StringTheSet-Cookieheader.static final StringTheSet-Cookie2header.static final StringTheUser-Agentheader.static final StringTheWWW-Authenticateheader.private static final org.slf4j.Loggerstatic final StringTheGETHTTP method.static final StringTheHEADHTTP method.static final StringThePOSTHTTP method.static final StringThePOSTHTTP method.static final StringThe standardtext/plainMIME type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidconfigureTLS(SSLSocket socket) Enables all supported TLS protocol versions on the socket given.static voidDisable SSL and hostname verification for given HTTP connectionstatic voidencode(StringBuilder urlstr, String key) URL encode a value string into an output buffer.private static StringgetProperty(String property) static ProxyproxyFor(ProxySelector proxySelector, URL u) Determine the proxy server (if any) needed to obtain a URL.static intGet the HTTP response code from the request.static intGet the HTTP response code from the request.static StringresponseHeader(HttpConnection c, String headerName) Extract a HTTP header from the response.static intScan a RFC 7230 token as it appears in HTTP headers.
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
METHOD_GET
TheGETHTTP method.- See Also:
-
METHOD_HEAD
TheHEADHTTP method.- Since:
- 4.3
- See Also:
-
METHOD_PUT
ThePOSTHTTP method.- Since:
- 4.3
- See Also:
-
METHOD_POST
ThePOSTHTTP method.- See Also:
-
HDR_CACHE_CONTROL
TheCache-Controlheader.- See Also:
-
HDR_PRAGMA
ThePragmaheader.- See Also:
-
HDR_USER_AGENT
TheUser-Agentheader.- See Also:
-
HDR_SERVER
TheServerheader.- Since:
- 4.0
- See Also:
-
HDR_DATE
TheDateheader.- See Also:
-
HDR_EXPIRES
TheExpiresheader.- See Also:
-
HDR_ETAG
TheETagheader.- See Also:
-
HDR_IF_NONE_MATCH
TheIf-None-Matchheader.- See Also:
-
HDR_LAST_MODIFIED
TheLast-Modifiedheader.- See Also:
-
HDR_IF_MODIFIED_SINCE
TheIf-Modified-Sinceheader.- See Also:
-
HDR_ACCEPT
TheAcceptheader.- See Also:
-
HDR_CONTENT_TYPE
TheContent-Typeheader.- See Also:
-
HDR_CONTENT_LENGTH
TheContent-Lengthheader.- See Also:
-
HDR_CONTENT_ENCODING
TheContent-Encodingheader.- See Also:
-
HDR_CONTENT_RANGE
TheContent-Rangeheader.- See Also:
-
HDR_ACCEPT_RANGES
TheAccept-Rangesheader.- See Also:
-
HDR_IF_RANGE
TheIf-Rangeheader.- See Also:
-
HDR_RANGE
TheRangeheader.- See Also:
-
HDR_ACCEPT_ENCODING
TheAccept-Encodingheader.- See Also:
-
HDR_LOCATION
TheLocationheader.- Since:
- 4.7
- See Also:
-
ENCODING_GZIP
Thegzipencoding value forHDR_ACCEPT_ENCODING.- See Also:
-
ENCODING_X_GZIP
Thex-gzipencoding value forHDR_ACCEPT_ENCODING.- Since:
- 4.6
- See Also:
-
TEXT_PLAIN
The standardtext/plainMIME type.- See Also:
-
HDR_AUTHORIZATION
TheAuthorizationheader.- See Also:
-
HDR_WWW_AUTHENTICATE
TheWWW-Authenticateheader.- See Also:
-
HDR_COOKIE
TheCookieheader.- Since:
- 5.4
- See Also:
-
HDR_SET_COOKIE
TheSet-Cookieheader.- Since:
- 5.4
- See Also:
-
HDR_SET_COOKIE2
TheSet-Cookie2header.- Since:
- 5.4
- See Also:
-
configuredHttpsProtocols
-
-
Constructor Details
-
HttpSupport
private HttpSupport()
-
-
Method Details
-
encode
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
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
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.
-
responseHeader
Extract a HTTP header from the response.- Parameters:
c- connection the header should be obtained from.headerName- the header name- Returns:
- the header value
- Throws:
IOException- communications error prevented obtaining the header.- Since:
- 4.7
-
proxyFor
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.
-
disableSslVerify
Disable SSL and hostname verification for given HTTP connection- Parameters:
conn- aHttpConnectionobject.- Throws:
IOException- Since:
- 4.3
-
configureTLS
Enables all supported TLS protocol versions on the socket given. If system property "https.protocols" is set, only protocols specified there are enabled.This is primarily a mechanism to deal with using TLS on IBM JDK. IBM JDK returns sockets that support all TLS protocol versions but have only the one specified in the context enabled. Oracle or OpenJDK return sockets that have all available protocols enabled already, up to the one specified.
SSLContext.getInstance() OpenJDK IDM JDK "TLS" Supported: TLSv1, TLSV1.1, TLSv1.2 (+ TLSv1.3)
Enabled: TLSv1, TLSV1.1, TLSv1.2 (+ TLSv1.3)Supported: TLSv1, TLSV1.1, TLSv1.2
Enabled: TLSv1"TLSv1.2" Supported: TLSv1, TLSV1.1, TLSv1.2
Enabled: TLSv1, TLSV1.1, TLSv1.2Supported: TLSv1, TLSV1.1, TLSv1.2
Enabled: TLSv1.2- Parameters:
socket- to configure- Since:
- 5.7
- See Also:
-
getConfiguredProtocols
-
getProperty
-
scanToken
Scan a RFC 7230 token as it appears in HTTP headers.- Parameters:
header- to scan infrom- index inheaderto start scanning at- Returns:
- the index after the token, that is, on the first non-token
character or
header.length - Throws:
IndexOutOfBoundsException- iffrom < 0orfrom > header.length()- Since:
- 5.10
- See Also:
-