Class HttpClient
java.lang.Object
org.sblim.cimclient.internal.http.HttpClient
- All Implemented Interfaces:
EventListener, HandshakeCompletedListener
Class HttpClient implements a HTTP client
-
Constructor Summary
ConstructorsConstructorDescriptionHttpClient
(URI url, HttpClientPool clientPool, AuthorizationHandler auth_handler) Ctor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
connect()
Connects to the http serverstatic String
convertToHexString
(byte[] digest) Converts a byte array to a String of hex digitsprotected static String
void
Disconnects the sessionprotected void
finalize()
protected AuthorizationInfo
getAuthentication
(boolean proxy, AuthorizationInfo prevAuthInfo, String authenticate) static HttpClient
getClient
(URI url, HttpClientPool clientPool, AuthorizationHandler auth_handler) Returns a client from a http client poolgetHeaderField
(String name) Returns the http header field for a given namegetHeaderFieldName
(int index) Return the http header field name for a given indexgetHeaderFieldValue
(int index) Returns the http header field value for a given indexReturns the input stream of this http connectionReturns the output stream of this http connectionReturns the request methodgetRequestProperty
(String key) Returns the request property for a given keyint
Returns the response codeReturns the response messageprotected static void
handleRsp
(String authInfo, AuthorizationInfo prevAuthInfo) void
boolean
Returns connectedprotected static byte[]
void
reset()
Resets statevoid
setRequestMethod
(String method) Sets the request methodvoid
setRequestProperty
(String key, String value) Sets the request propertyvoid
Releases the client and returns it to the poolvoid
streamFinished
(boolean keep) Releases the client and returns it to the pooltoString()
void
useHttp11
(boolean bool) Enables/Disables use of http 1.1boolean
Returns if a proxy is used
-
Constructor Details
-
HttpClient
Ctor.- Parameters:
url
- The url to connect toclientPool
- The associated client poolauth_handler
- The authentication handler
-
-
Method Details
-
convertToHexString
Converts a byte array to a String of hex digits- Parameters:
digest
- The byte array- Returns:
- The hex string
-
getClient
public static HttpClient getClient(URI url, HttpClientPool clientPool, AuthorizationHandler auth_handler) Returns a client from a http client pool- Parameters:
url
- The url to connect toclientPool
- The client poolauth_handler
- The authentication handler to use- Returns:
- A http client from the pool
-
dequote
-
handleRsp
- Throws:
IOException
-
parseHex
-
connect
-
disconnect
public void disconnect()Disconnects the session -
finalize
-
getHeaderFieldValue
Returns the http header field value for a given index- Parameters:
index
- The index- Returns:
- The header field value
-
getHeaderField
-
getHeaderFieldName
Return the http header field name for a given index- Parameters:
index
- The index- Returns:
- The name
-
getInputStream
Returns the input stream of this http connection- Returns:
- The input stream
- Throws:
IOException
-
getOutputStream
Returns the output stream of this http connection- Returns:
- The output stream
-
getRequestMethod
-
getRequestProperty
-
getResponseCode
Returns the response code- Returns:
- The response code
- Throws:
IOException
-
getResponseMessage
-
handshakeCompleted
- Specified by:
handshakeCompleted
in interfaceHandshakeCompletedListener
-
reset
public void reset()Resets state -
setRequestMethod
Sets the request method- Parameters:
method
- The request method
-
setRequestProperty
-
streamFinished
public void streamFinished()Releases the client and returns it to the pool -
streamFinished
public void streamFinished(boolean keep) Releases the client and returns it to the pool- Parameters:
keep
- iftrue
return to the pool, iffalse
drop.
-
useHttp11
public void useHttp11(boolean bool) Enables/Disables use of http 1.1- Parameters:
bool
- iftrue
http 1.1 is enabled.
-
usingProxy
public boolean usingProxy()Returns if a proxy is used- Returns:
true
if a proxy is used
-
getAuthentication
protected AuthorizationInfo getAuthentication(boolean proxy, AuthorizationInfo prevAuthInfo, String authenticate) throws HttpParseException, NoSuchAlgorithmException -
isConnected
public boolean isConnected()Returns connected- Returns:
- The value of connected.
-
toString
-