HttpConnector¶
-
public class
HttpConnector
¶ HttpConnector is a connector for making HTTP/S connections to an URL.
Author: Hugo Y. K. Lam
Constructors¶
Methods¶
addKeyManager¶
-
public void
addKeyManager
(KeyManager km)¶ Adds a key manager for SSL connection.
Parameters: - km – the key manager.
addTrustManager¶
-
public void
addTrustManager
(TrustManager tm)¶ Adds a trust manager for SSL connection.
Parameters: - tm – the trust manager.
createConnection¶
-
public HttpURLConnection
createConnection
()¶ Creates a new HTTP connection based on this connector’s properties.
Throws: - ConnectionException – if unable to create a new HTTP connection.
Returns: a new HTTP connection.
getHostnameVerifier¶
-
public HostnameVerifier
getHostnameVerifier
()¶ Gets the host verifier for SSL connection.
Returns: the host name verifier.
getRequestHeaders¶
getSSLSocketFactory¶
-
public SSLSocketFactory
getSSLSocketFactory
()¶ Gets the SSL socket factory which is used in SSL connection.
Throws: - ConnectionException – if unable to create SSL socket factory.
Returns: the SSL socket factory.
send¶
-
public InputStream
send
(InputStream request)¶ Sends an HTTP/S request using the given HTTP connection.
Parameters: - request – the HTTP request content or null for a simple get request.
Throws: - ConnectionException – if failed in sending the HTTP request or creating a new connection.
Returns: an input stream for reading the reply from the host.
send¶
-
public InputStream
send
(InputStream request, HttpURLConnection connection)¶ Sends an HTTP/S request using the given HTTP connection.
Parameters: - request – the HTTP request content or null for a simple get request.
- connection – the HTTP connection for sending the request.
Throws: - ConnectionException – if failed in sending the HTTP request.
Returns: an input stream for reading the reply from the host.
setHostnameVerifier¶
-
public void
setHostnameVerifier
(HostnameVerifier hostnameVerifier)¶ Sets a host name verifier for SSL connection.
Parameters: - hostnameVerifier – the host name verifier.