public class HttpSupport extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ENCODING_GZIP
The
gzip encoding value for HDR_ACCEPT_ENCODING . |
static String |
ENCODING_X_GZIP
The
x-gzip encoding value for HDR_ACCEPT_ENCODING . |
static String |
HDR_ACCEPT
The
Accept header. |
static String |
HDR_ACCEPT_ENCODING
The
Accept-Encoding header. |
static String |
HDR_ACCEPT_RANGES
The
Accept-Ranges header. |
static String |
HDR_AUTHORIZATION
The
Authorization header. |
static String |
HDR_CACHE_CONTROL
The
Cache-Control header. |
static String |
HDR_CONTENT_ENCODING
The
Content-Encoding header. |
static String |
HDR_CONTENT_LENGTH
The
Content-Length header. |
static String |
HDR_CONTENT_RANGE
The
Content-Range header. |
static String |
HDR_CONTENT_TYPE
The
Content-Type header. |
static String |
HDR_COOKIE
The
Cookie header. |
static String |
HDR_DATE
The
Date header. |
static String |
HDR_ETAG
The
ETag header. |
static String |
HDR_EXPIRES
The
Expires header. |
static String |
HDR_IF_MODIFIED_SINCE
The
If-Modified-Since header. |
static String |
HDR_IF_NONE_MATCH
The
If-None-Match header. |
static String |
HDR_IF_RANGE
The
If-Range header. |
static String |
HDR_LAST_MODIFIED
The
Last-Modified header. |
static String |
HDR_LOCATION
The
Location header. |
static String |
HDR_PRAGMA
The
Pragma header. |
static String |
HDR_RANGE
The
Range header. |
static String |
HDR_SERVER
The
Server header. |
static String |
HDR_SET_COOKIE
The
Set-Cookie header. |
static String |
HDR_SET_COOKIE2
The
Set-Cookie2 header. |
static String |
HDR_USER_AGENT
The
User-Agent header. |
static String |
HDR_WWW_AUTHENTICATE
The
WWW-Authenticate header. |
static String |
METHOD_GET
The
GET HTTP method. |
static String |
METHOD_HEAD
The
HEAD HTTP method. |
static String |
METHOD_POST
The
POST HTTP method. |
static String |
METHOD_PUT
The
POST HTTP method. |
static String |
TEXT_PLAIN
The standard
text/plain MIME type. |
Modifier and Type | Method and Description |
---|---|
static void |
configureTLS(SSLSocket socket)
Enables all supported TLS protocol versions on the socket given.
|
static void |
disableSslVerify(HttpConnection conn)
Disable SSL and hostname verification for given HTTP connection
|
static void |
encode(StringBuilder urlstr,
String key)
URL encode a value string into an output buffer.
|
static Proxy |
proxyFor(ProxySelector proxySelector,
URL u)
Determine the proxy server (if any) needed to obtain a URL.
|
static int |
response(HttpConnection c)
Get the HTTP response code from the request.
|
static int |
response(HttpURLConnection c)
Get the HTTP response code from the request.
|
static String |
responseHeader(HttpConnection c,
String headerName)
Extract a HTTP header from the response.
|
public static final String METHOD_GET
GET
HTTP method.public static final String METHOD_HEAD
HEAD
HTTP method.public static final String METHOD_PUT
POST
HTTP method.public static final String METHOD_POST
POST
HTTP method.public static final String HDR_CACHE_CONTROL
Cache-Control
header.public static final String HDR_PRAGMA
Pragma
header.public static final String HDR_USER_AGENT
User-Agent
header.public static final String HDR_SERVER
Server
header.public static final String HDR_DATE
Date
header.public static final String HDR_EXPIRES
Expires
header.public static final String HDR_ETAG
ETag
header.public static final String HDR_IF_NONE_MATCH
If-None-Match
header.public static final String HDR_LAST_MODIFIED
Last-Modified
header.public static final String HDR_IF_MODIFIED_SINCE
If-Modified-Since
header.public static final String HDR_ACCEPT
Accept
header.public static final String HDR_CONTENT_TYPE
Content-Type
header.public static final String HDR_CONTENT_LENGTH
Content-Length
header.public static final String HDR_CONTENT_ENCODING
Content-Encoding
header.public static final String HDR_CONTENT_RANGE
Content-Range
header.public static final String HDR_ACCEPT_RANGES
Accept-Ranges
header.public static final String HDR_IF_RANGE
If-Range
header.public static final String HDR_RANGE
Range
header.public static final String HDR_ACCEPT_ENCODING
Accept-Encoding
header.public static final String HDR_LOCATION
Location
header.public static final String ENCODING_GZIP
gzip
encoding value for HDR_ACCEPT_ENCODING
.public static final String ENCODING_X_GZIP
x-gzip
encoding value for HDR_ACCEPT_ENCODING
.public static final String TEXT_PLAIN
text/plain
MIME type.public static final String HDR_AUTHORIZATION
Authorization
header.public static final String HDR_WWW_AUTHENTICATE
WWW-Authenticate
header.public static final String HDR_COOKIE
Cookie
header.public static final String HDR_SET_COOKIE
Set-Cookie
header.public static final String HDR_SET_COOKIE2
Set-Cookie2
header.public static void encode(StringBuilder urlstr, String key)
urlstr
- the output buffer.key
- value which must be encoded to protected special characters.public static int response(HttpConnection c) throws IOException
Roughly the same as c.getResponseCode()
but the
ConnectException is translated to be more understandable.
c
- connection the code should be obtained from.HttpConnection
for other
defined constants.IOException
- communications error prevented obtaining the response code.public static int response(HttpURLConnection c) throws IOException
Roughly the same as c.getResponseCode()
but the
ConnectException is translated to be more understandable.
c
- connection the code should be obtained from.HttpConnection
for other
defined constants.IOException
- communications error prevented obtaining the response code.public static String responseHeader(HttpConnection c, String headerName) throws IOException
c
- connection the header should be obtained from.headerName
- the header nameIOException
- communications error prevented obtaining the header.public static Proxy proxyFor(ProxySelector proxySelector, URL u) throws ConnectException
proxySelector
- proxy support for the caller.u
- location of the server caller wants to talk to.ConnectException
- the proxy could not be computed as the supplied URL could not
be read. This failure should never occur.public static void disableSslVerify(HttpConnection conn) throws IOException
conn
- a HttpConnection
object.IOException
public static void configureTLS(SSLSocket socket)
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.2 |
Supported: TLSv1, TLSV1.1, TLSv1.2 Enabled: TLSv1.2 |
socket
- to configureCopyright © 2020 Eclipse JGit Project. All rights reserved.