public class UrlConnectionHttpClient extends Object implements IHttpClient
Modifier and Type | Class and Description |
---|---|
class |
UrlConnectionHttpClient.CallbackTrustManager |
Modifier and Type | Field and Description |
---|---|
protected String |
acceptedMediaType |
protected String |
acceptedVersion |
protected Integer |
configTimeout |
protected ISSLCertificateCallback |
sslAuthorizationCallback |
protected String |
userAgent |
AMPERSAND, AUTHORIZATION_BASIC, AUTHORIZATION_BEARER, COLON, COMMA, DEFAULT_READ_TIMEOUT, EQUALS, HTTP, MEDIATYPE_APPLICATION_FORMURLENCODED, MEDIATYPE_APPLICATION_JSON, MEDIATYPE_APPLICATION_XML, NO_TIMEOUT, PROPERTY_ACCEPT, PROPERTY_AUTHIV, PROPERTY_AUTHKEY, PROPERTY_AUTHORIZATION, PROPERTY_CONTENT_TYPE, PROPERTY_USER_AGENT, QUESTION_MARK, SEMICOLON, SLASH, SPACE, SYSPROP_DEFAULT_CONNECT_TIMEOUT, SYSPROP_DEFAULT_READ_TIMEOUT, SYSPROP_OPENSHIFT_CONNECT_TIMEOUT, SYSPROP_OPENSHIFT_READ_TIMEOUT, VERSION
STATUS_BAD_REQUEST, STATUS_FORBIDDEN, STATUS_INTERNAL_SERVER_ERROR, STATUS_NOT_FOUND, STATUS_OK, STATUS_UNAUTHORIZED
Constructor and Description |
---|
UrlConnectionHttpClient(String userAgent,
String acceptedMediaType,
String version) |
UrlConnectionHttpClient(String userAgent,
String acceptedMediaType,
String version,
ISSLCertificateCallback callback,
Integer configTimeout,
String excludedSSLCipherRegex) |
Modifier and Type | Method and Description |
---|---|
protected HttpURLConnection |
createConnection(URL url,
String userAgent,
String acceptedVersion,
String acceptedMediaType,
ISSLCertificateCallback callback,
int timeout) |
protected String |
createErrorMessage(IOException ioe,
HttpURLConnection connection) |
String |
delete(URL url,
IMediaType mediaType,
int timeout,
Parameter... parameters) |
String |
delete(URL url,
int timeout) |
String |
get(URL url,
int timeout) |
protected String[] |
getSupportedCiphers(SSLContext sslContext) |
String |
head(URL url,
int timeout) |
String |
post(URL url,
int timeout,
IResource resource) |
String |
put(URL url,
IMediaType mediaType,
int timeout,
Parameter... parameters) |
String |
put(URL url,
int timeout,
IResource resource) |
protected String |
request(HttpMethod httpMethod,
URL url,
IMediaType requestMediaType,
int timeout,
Parameter... parameters) |
protected String |
request(HttpMethod httpMethod,
URL url,
IMediaType requestMediaType,
int timeout,
ParameterValueMap parameters) |
protected String |
request(HttpMethod httpMethod,
URL url,
int timeout,
IResource resource) |
void |
setAcceptedMediaType(String acceptedMediaType) |
void |
setAcceptVersion(String version) |
protected void |
setAuthorization(HttpURLConnection connection) |
void |
setAuthorizationStrategy(IAuthorizationStrategy strategy) |
protected SSLContext |
setFilteredCiphers(String excludedSSLCipherRegex,
SSLContext sslContext,
HttpsURLConnection connection)
Sets a ssl socket factory that sets a filtered list of ciphers based on
the #excludedSSLCipherRegex to the given connection.
|
void |
setUserAgent(String userAgent) |
protected String userAgent
protected String acceptedMediaType
protected String acceptedVersion
protected ISSLCertificateCallback sslAuthorizationCallback
protected Integer configTimeout
public UrlConnectionHttpClient(String userAgent, String acceptedMediaType, String version)
public void setAuthorizationStrategy(IAuthorizationStrategy strategy)
setAuthorizationStrategy
in interface IHttpClient
public String get(URL url, int timeout) throws HttpClientException, SocketTimeoutException
get
in interface IHttpClient
HttpClientException
SocketTimeoutException
public String head(URL url, int timeout) throws HttpClientException, SocketTimeoutException
head
in interface IHttpClient
HttpClientException
SocketTimeoutException
public String put(URL url, IMediaType mediaType, int timeout, Parameter... parameters) throws HttpClientException, SocketTimeoutException, EncodingException
public String put(URL url, int timeout, IResource resource) throws HttpClientException, SocketTimeoutException, EncodingException
put
in interface IHttpClient
HttpClientException
SocketTimeoutException
EncodingException
public String post(URL url, int timeout, IResource resource) throws HttpClientException, SocketTimeoutException, EncodingException
post
in interface IHttpClient
HttpClientException
SocketTimeoutException
EncodingException
public String delete(URL url, IMediaType mediaType, int timeout, Parameter... parameters) throws HttpClientException, SocketTimeoutException, EncodingException
public String delete(URL url, int timeout) throws HttpClientException, SocketTimeoutException, EncodingException
delete
in interface IHttpClient
HttpClientException
SocketTimeoutException
EncodingException
protected String request(HttpMethod httpMethod, URL url, IMediaType requestMediaType, int timeout, Parameter... parameters) throws SocketTimeoutException, HttpClientException
protected String request(HttpMethod httpMethod, URL url, IMediaType requestMediaType, int timeout, ParameterValueMap parameters) throws SocketTimeoutException, HttpClientException
protected String request(HttpMethod httpMethod, URL url, int timeout, IResource resource) throws SocketTimeoutException, HttpClientException
protected String createErrorMessage(IOException ioe, HttpURLConnection connection) throws IOException
IOException
protected HttpURLConnection createConnection(URL url, String userAgent, String acceptedVersion, String acceptedMediaType, ISSLCertificateCallback callback, int timeout) throws IOException
IOException
protected final void setAuthorization(HttpURLConnection connection)
protected SSLContext setFilteredCiphers(String excludedSSLCipherRegex, SSLContext sslContext, HttpsURLConnection connection)
sslContext
- sslContext
- the ssl context that shall be usedurl
- the url we are connecting toconnection
- the connection that the cipher filter shall be applied toprotected String[] getSupportedCiphers(SSLContext sslContext)
public void setUserAgent(String userAgent)
setUserAgent
in interface IHttpClient
public void setAcceptVersion(String version)
setAcceptVersion
in interface IHttpClient
public void setAcceptedMediaType(String acceptedMediaType)
setAcceptedMediaType
in interface IHttpClient
Copyright © 2016 Red Hat, Inc. All rights reserved.