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 TypeMethodDescriptionvoidconnect()Connects to the http serverstatic StringconvertToHexString(byte[] digest) Converts a byte array to a String of hex digitsprotected static StringvoidDisconnects the sessionprotected voidfinalize()protected AuthorizationInfogetAuthentication(boolean proxy, AuthorizationInfo prevAuthInfo, String authenticate) static HttpClientgetClient(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 keyintReturns the response codeReturns the response messageprotected static voidhandleRsp(String authInfo, AuthorizationInfo prevAuthInfo) voidbooleanReturns connectedprotected static byte[]voidreset()Resets statevoidsetRequestMethod(String method) Sets the request methodvoidsetRequestProperty(String key, String value) Sets the request propertyvoidReleases the client and returns it to the poolvoidstreamFinished(boolean keep) Releases the client and returns it to the pooltoString()voiduseHttp11(boolean bool) Enables/Disables use of http 1.1booleanReturns 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:
handshakeCompletedin 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- iftruereturn to the pool, iffalsedrop.
-
useHttp11
public void useHttp11(boolean bool) Enables/Disables use of http 1.1- Parameters:
bool- iftruehttp 1.1 is enabled.
-
usingProxy
public boolean usingProxy()Returns if a proxy is used- Returns:
trueif 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
-