public class HttpSupport
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
HttpSupport.DummyHostnameVerifier |
private static class |
HttpSupport.DummyX509TrustManager |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ENCODING_GZIP
The
gzip encoding value for HDR_ACCEPT_ENCODING . |
static java.lang.String |
ENCODING_X_GZIP
The
x-gzip encoding value for HDR_ACCEPT_ENCODING . |
static java.lang.String |
HDR_ACCEPT
The
Accept header. |
static java.lang.String |
HDR_ACCEPT_ENCODING
The
Accept-Encoding header. |
static java.lang.String |
HDR_ACCEPT_RANGES
The
Accept-Ranges header. |
static java.lang.String |
HDR_AUTHORIZATION
The
Authorization header. |
static java.lang.String |
HDR_CACHE_CONTROL
The
Cache-Control header. |
static java.lang.String |
HDR_CONTENT_ENCODING
The
Content-Encoding header. |
static java.lang.String |
HDR_CONTENT_LENGTH
The
Content-Length header. |
static java.lang.String |
HDR_CONTENT_RANGE
The
Content-Range header. |
static java.lang.String |
HDR_CONTENT_TYPE
The
Content-Type header. |
static java.lang.String |
HDR_COOKIE
The
Cookie header. |
static java.lang.String |
HDR_DATE
The
Date header. |
static java.lang.String |
HDR_ETAG
The
ETag header. |
static java.lang.String |
HDR_EXPIRES
The
Expires header. |
static java.lang.String |
HDR_IF_MODIFIED_SINCE
The
If-Modified-Since header. |
static java.lang.String |
HDR_IF_NONE_MATCH
The
If-None-Match header. |
static java.lang.String |
HDR_IF_RANGE
The
If-Range header. |
static java.lang.String |
HDR_LAST_MODIFIED
The
Last-Modified header. |
static java.lang.String |
HDR_LOCATION
The
Location header. |
static java.lang.String |
HDR_PRAGMA
The
Pragma header. |
static java.lang.String |
HDR_RANGE
The
Range header. |
static java.lang.String |
HDR_SERVER
The
Server header. |
static java.lang.String |
HDR_SET_COOKIE
The
Set-Cookie header. |
static java.lang.String |
HDR_SET_COOKIE2
The
Set-Cookie2 header. |
static java.lang.String |
HDR_USER_AGENT
The
User-Agent header. |
static java.lang.String |
HDR_WWW_AUTHENTICATE
The
WWW-Authenticate header. |
static java.lang.String |
METHOD_GET
The
GET HTTP method. |
static java.lang.String |
METHOD_HEAD
The
HEAD HTTP method. |
static java.lang.String |
METHOD_POST
The
POST HTTP method. |
static java.lang.String |
METHOD_PUT
The
POST HTTP method. |
static java.lang.String |
TEXT_PLAIN
The standard
text/plain MIME type. |
Modifier | Constructor and Description |
---|---|
private |
HttpSupport() |
Modifier and Type | Method and Description |
---|---|
static void |
disableSslVerify(HttpConnection conn)
Disable SSL and hostname verification for given HTTP connection
|
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(HttpConnection c)
Get the HTTP response code from the request.
|
static int |
response(java.net.HttpURLConnection c)
Get the HTTP response code from the request.
|
static java.lang.String |
responseHeader(HttpConnection c,
java.lang.String headerName)
Extract a HTTP header from the response.
|
public static final java.lang.String METHOD_GET
GET
HTTP method.public static final java.lang.String METHOD_HEAD
HEAD
HTTP method.public static final java.lang.String METHOD_PUT
POST
HTTP method.public static final java.lang.String METHOD_POST
POST
HTTP method.public static final java.lang.String HDR_CACHE_CONTROL
Cache-Control
header.public static final java.lang.String HDR_PRAGMA
Pragma
header.public static final java.lang.String HDR_USER_AGENT
User-Agent
header.public static final java.lang.String HDR_SERVER
Server
header.public static final java.lang.String HDR_DATE
Date
header.public static final java.lang.String HDR_EXPIRES
Expires
header.public static final java.lang.String HDR_ETAG
ETag
header.public static final java.lang.String HDR_IF_NONE_MATCH
If-None-Match
header.public static final java.lang.String HDR_LAST_MODIFIED
Last-Modified
header.public static final java.lang.String HDR_IF_MODIFIED_SINCE
If-Modified-Since
header.public static final java.lang.String HDR_ACCEPT
Accept
header.public static final java.lang.String HDR_CONTENT_TYPE
Content-Type
header.public static final java.lang.String HDR_CONTENT_LENGTH
Content-Length
header.public static final java.lang.String HDR_CONTENT_ENCODING
Content-Encoding
header.public static final java.lang.String HDR_CONTENT_RANGE
Content-Range
header.public static final java.lang.String HDR_ACCEPT_RANGES
Accept-Ranges
header.public static final java.lang.String HDR_IF_RANGE
If-Range
header.public static final java.lang.String HDR_RANGE
Range
header.public static final java.lang.String HDR_ACCEPT_ENCODING
Accept-Encoding
header.public static final java.lang.String HDR_LOCATION
Location
header.public static final java.lang.String ENCODING_GZIP
gzip
encoding value for HDR_ACCEPT_ENCODING
.public static final java.lang.String ENCODING_X_GZIP
x-gzip
encoding value for HDR_ACCEPT_ENCODING
.public static final java.lang.String TEXT_PLAIN
text/plain
MIME type.public static final java.lang.String HDR_AUTHORIZATION
Authorization
header.public static final java.lang.String HDR_WWW_AUTHENTICATE
WWW-Authenticate
header.public static final java.lang.String HDR_COOKIE
Cookie
header.public static final java.lang.String HDR_SET_COOKIE
Set-Cookie
header.public static final java.lang.String HDR_SET_COOKIE2
Set-Cookie2
header.public static void encode(java.lang.StringBuilder urlstr, java.lang.String key)
urlstr
- the output buffer.key
- value which must be encoded to protected special characters.public static int response(HttpConnection c) throws java.io.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.java.io.IOException
- communications error prevented obtaining the response code.public static int response(java.net.HttpURLConnection c) throws java.io.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.java.io.IOException
- communications error prevented obtaining the response code.public static java.lang.String responseHeader(HttpConnection c, java.lang.String headerName) throws java.io.IOException
c
- connection the header should be obtained from.headerName
- the header namejava.io.IOException
- communications error prevented obtaining the header.public static java.net.Proxy proxyFor(java.net.ProxySelector proxySelector, java.net.URL u) throws java.net.ConnectException
proxySelector
- proxy support for the caller.u
- location of the server caller wants to talk to.java.net.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 java.io.IOException
conn
- a HttpConnection
object.java.io.IOException