org.sblim.cimclient.internal.http

Class HttpClient

public class HttpClient extends Object implements HandshakeCompletedListener

Class HttpClient implements a HTTP client
Constructor Summary
HttpClient(URI url, HttpClientPool clientPool, AuthorizationHandler auth_handler)
Ctor.
Method Summary
voidconnect()
Connects to the http server
static StringconvertToHexString(byte[] digest)
Converts a byte array to a String of hex digits
protected static Stringdequote(String str)
voiddisconnect()
Disconnects the session
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 pool
StringgetHeaderField(String name)
Returns the http header field for a given name
StringgetHeaderFieldName(int index)
Return the http header field name for a given index
StringgetHeaderFieldValue(int index)
Returns the http header field value for a given index
InputStreamgetInputStream()
Returns the input stream of this http connection
OutputStreamgetOutputStream()
Returns the output stream of this http connection
StringgetRequestMethod()
Returns the request method
StringgetRequestProperty(String key)
Returns the request property for a given key
intgetResponseCode()
Returns the response code
StringgetResponseMessage()
Returns the response message
protected static voidhandleRsp(String authInfo, AuthorizationInfo prevAuthInfo)
voidhandshakeCompleted(HandshakeCompletedEvent event)
booleanisConnected()
Returns connected
protected static byte[]parseHex(String hex)
voidreset()
Resets state
voidsetRequestMethod(String method)
Sets the request method
voidsetRequestProperty(String key, String value)
Sets the request property
voidstreamFinished()
Releases the client and returns it to the pool
voidstreamFinished(boolean keep)
Releases the client and returns it to the pool
StringtoString()
voiduseHttp11(boolean bool)
Enables/Disables use of http 1.1
booleanusingProxy()
Returns if a proxy is used

Constructor Detail

HttpClient

public HttpClient(URI url, HttpClientPool clientPool, AuthorizationHandler auth_handler)
Ctor.

Parameters: url The url to connect to clientPool The associated client pool auth_handler The authentication handler

Method Detail

connect

public void connect()
Connects to the http server

Throws: IOException

convertToHexString

public static String convertToHexString(byte[] digest)
Converts a byte array to a String of hex digits

Parameters: digest The byte array

Returns: The hex string

dequote

protected static String dequote(String str)

disconnect

public void disconnect()
Disconnects the session

finalize

public void finalize()

getAuthentication

protected AuthorizationInfo getAuthentication(boolean proxy, AuthorizationInfo prevAuthInfo, String authenticate)

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 to clientPool The client pool auth_handler The authentication handler to use

Returns: A http client from the pool

getHeaderField

public String getHeaderField(String name)
Returns the http header field for a given name

Parameters: name The name

Returns: The header field

getHeaderFieldName

public String getHeaderFieldName(int index)
Return the http header field name for a given index

Parameters: index The index

Returns: The name

getHeaderFieldValue

public String getHeaderFieldValue(int index)
Returns the http header field value for a given index

Parameters: index The index

Returns: The header field value

getInputStream

public InputStream getInputStream()
Returns the input stream of this http connection

Returns: The input stream

Throws: IOException

getOutputStream

public OutputStream getOutputStream()
Returns the output stream of this http connection

Returns: The output stream

getRequestMethod

public String getRequestMethod()
Returns the request method

Returns: The request method

getRequestProperty

public String getRequestProperty(String key)
Returns the request property for a given key

Parameters: key The key

Returns: The property

getResponseCode

public int getResponseCode()
Returns the response code

Returns: The response code

Throws: IOException

getResponseMessage

public String getResponseMessage()
Returns the response message

Returns: The response message

handleRsp

protected static void handleRsp(String authInfo, AuthorizationInfo prevAuthInfo)

handshakeCompleted

public void handshakeCompleted(HandshakeCompletedEvent event)

isConnected

public boolean isConnected()
Returns connected

Returns: The value of connected.

parseHex

protected static byte[] parseHex(String hex)

reset

public void reset()
Resets state

setRequestMethod

public void setRequestMethod(String method)
Sets the request method

Parameters: method The request method

setRequestProperty

public void setRequestProperty(String key, String value)
Sets the request property

Parameters: key The property name value The value

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 if true return to the pool, if false drop.

toString

public String toString()

useHttp11

public void useHttp11(boolean bool)
Enables/Disables use of http 1.1

Parameters: bool if true http 1.1 is enabled.

usingProxy

public boolean usingProxy()
Returns if a proxy is used

Returns: true if a proxy is used

Copyright © 2005, 2009 IBM Corporation. All Rights Reserved.