public class HttpClient extends AggregateLifeCycle implements HttpBuffers, Attributes, Dumpable
setConnectorType(int)).
The an instance of HttpExchange is passed to the send(HttpExchange) method
to send a request. The exchange contains both the headers and content (source) of the request
plus the callbacks to handle responses. A HttpClient can have many exchanges outstanding
and they may be queued on the HttpDestination waiting for a AbstractHttpConnection,
queued in the AbstractHttpConnection waiting to be transmitted or pipelined on the actual
TCP/IP connection waiting for a response.
The HttpDestination class is an aggregation of AbstractHttpConnections for the
same host, port and protocol. A destination may limit the number of connections
open and they provide a pool of open connections that may be reused. Connections may also
be allocated from a destination, so that multiple request sources are not multiplexed
over the same connection.HttpExchange,
HttpDestinationAbstractLifeCycle.AbstractLifeCycleListenerLifeCycle.Listener| Modifier and Type | Field and Description |
|---|---|
static int |
CONNECTOR_SELECT_CHANNEL |
static int |
CONNECTOR_SOCKET |
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING| Constructor and Description |
|---|
HttpClient() |
HttpClient(SslContextFactory sslContextFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel(Timeout.Task task) |
void |
clearAttributes() |
protected void |
doStart()
Start the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stop the joined lifecycle beans in the reverse order they were added.
|
Object |
getAttribute(String name) |
Enumeration |
getAttributeNames() |
int |
getConnectorType()
Get the type of connector (socket, blocking or select) in use.
|
int |
getConnectTimeout() |
HttpDestination |
getDestination(Address remote,
boolean ssl) |
HttpDestination |
getDestination(Address remote,
boolean ssl,
SslContextFactory sslContextFactory) |
Collection<Address> |
getDestinations() |
long |
getIdleTimeout() |
String |
getKeyManagerAlgorithm()
Deprecated.
|
InputStream |
getKeyStoreInputStream()
Deprecated.
|
String |
getKeyStoreLocation()
Deprecated.
|
String |
getKeyStoreType()
Deprecated.
|
int |
getMaxBuffers() |
int |
getMaxConnectionsPerAddress() |
int |
getMaxQueueSizePerAddress() |
Set<String> |
getNoProxy() |
String |
getProtocol()
Deprecated.
|
String |
getProvider()
Deprecated.
|
Address |
getProxy() |
Authentication |
getProxyAuthentication() |
RealmResolver |
getRealmResolver()
returns the SecurityRealmResolver reg_realmResolveristered with the HttpClient or null
|
LinkedList<String> |
getRegisteredListeners() |
Buffers |
getRequestBuffers() |
int |
getRequestBufferSize() |
Buffers.Type |
getRequestBufferType() |
int |
getRequestHeaderSize() |
Buffers.Type |
getRequestHeaderType() |
Buffers |
getResponseBuffers() |
int |
getResponseBufferSize() |
Buffers.Type |
getResponseBufferType() |
int |
getResponseHeaderSize() |
Buffers.Type |
getResponseHeaderType() |
String |
getSecureRandomAlgorithm()
Deprecated.
|
int |
getSoTimeout()
Deprecated.
use
getTimeout() instead. |
protected SSLContext |
getSSLContext()
if a keystore location has been provided then client will attempt to use it as the keystore,
otherwise we simply ignore certificates and run with a loose ssl context.
|
SslContextFactory |
getSslContextFactory() |
ThreadPool |
getThreadPool() |
long |
getTimeout() |
String |
getTrustManagerAlgorithm()
Deprecated.
|
InputStream |
getTrustStoreInputStream()
Deprecated.
|
String |
getTrustStoreLocation()
Deprecated.
|
String |
getTrustStoreType()
Deprecated.
|
boolean |
getUseDirectBuffers()
Get whether the connector can use direct NIO buffers.
|
boolean |
hasRealms() |
boolean |
isConnectBlocking() |
boolean |
isProxied() |
boolean |
isRemoveIdleDestinations() |
int |
maxRedirects() |
int |
maxRetries() |
void |
registerListener(String listenerClass)
Registers a listener that can listen to the stream of execution between the client and the
server and influence events.
|
void |
removeAttribute(String name) |
void |
removeDestination(HttpDestination destination) |
void |
schedule(Timeout.Task task) |
void |
schedule(Timeout.Task task,
long timeout) |
void |
scheduleIdle(Timeout.Task task) |
void |
send(HttpExchange exchange) |
void |
setAttribute(String name,
Object attribute)
Set an attribute on the HttpClient.
|
void |
setConnectBlocking(boolean connectBlocking) |
void |
setConnectorType(int connectorType) |
void |
setConnectTimeout(int connectTimeout) |
void |
setIdleTimeout(long ms) |
void |
setKeyManagerAlgorithm(String keyManagerAlgorithm)
Deprecated.
|
void |
setKeyManagerPassword(String keyManagerPassword)
Deprecated.
|
void |
setKeyStoreInputStream(InputStream keyStoreInputStream)
Deprecated.
|
void |
setKeyStoreLocation(String keyStoreLocation)
Deprecated.
|
void |
setKeyStorePassword(String keyStorePassword)
Deprecated.
|
void |
setKeyStoreType(String keyStoreType)
Deprecated.
|
void |
setMaxBuffers(int maxBuffers) |
void |
setMaxConnectionsPerAddress(int maxConnectionsPerAddress) |
void |
setMaxQueueSizePerAddress(int maxQueueSizePerAddress) |
void |
setMaxRedirects(int redirects) |
void |
setMaxRetries(int retries) |
void |
setNoProxy(Set<String> noProxyAddresses) |
void |
setProtocol(String protocol)
Deprecated.
|
void |
setProvider(String provider)
Deprecated.
|
void |
setProxy(Address proxy) |
void |
setProxyAuthentication(Authentication authentication) |
void |
setRealmResolver(RealmResolver resolver)
Set a RealmResolver for client Authentication.
|
void |
setRemoveIdleDestinations(boolean removeIdleDestinations) |
void |
setRequestBuffers(Buffers requestBuffers) |
void |
setRequestBufferSize(int requestBufferSize) |
void |
setRequestHeaderSize(int requestHeaderSize) |
void |
setResponseBuffers(Buffers responseBuffers) |
void |
setResponseBufferSize(int responseBufferSize) |
void |
setResponseHeaderSize(int responseHeaderSize) |
void |
setSecureRandomAlgorithm(String secureRandomAlgorithm)
Deprecated.
|
void |
setSoTimeout(int timeout)
Deprecated.
use
setTimeout(long) instead. |
void |
setThreadPool(ThreadPool threadPool)
Set the ThreadPool.
|
void |
setTimeout(long timeout) |
void |
setTrustManagerAlgorithm(String trustManagerAlgorithm)
Deprecated.
|
void |
setTrustStoreInputStream(InputStream trustStoreInputStream)
Deprecated.
|
void |
setTrustStoreLocation(String trustStoreLocation)
Deprecated.
|
void |
setTrustStorePassword(String trustStorePassword)
Deprecated.
|
void |
setTrustStoreType(String trustStoreType)
Deprecated.
|
void |
setUseDirectBuffers(boolean direct)
Set to use NIO direct buffers.
|
addBean, addBean, contains, destroy, dump, dump, dump, dump, dump, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, unmanageaddLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stoppublic static final int CONNECTOR_SOCKET
public static final int CONNECTOR_SELECT_CHANNEL
public HttpClient()
public HttpClient(SslContextFactory sslContextFactory)
public boolean isConnectBlocking()
public void setConnectBlocking(boolean connectBlocking)
connectBlocking - True if connects will be in blocking mode.public boolean isRemoveIdleDestinations()
public void setRemoveIdleDestinations(boolean removeIdleDestinations)
public void send(HttpExchange exchange) throws IOException
IOExceptionpublic ThreadPool getThreadPool()
public void setThreadPool(ThreadPool threadPool)
AggregateLifeCycle.addBean(Object) so that
it's lifecycle may be managed as a AggregateLifeCycle.threadPool - the threadPool to setpublic Object getAttribute(String name)
getAttribute in interface Attributesname - public Enumeration getAttributeNames()
getAttributeNames in interface Attributespublic void removeAttribute(String name)
removeAttribute in interface Attributesname - public void setAttribute(String name, Object attribute)
setAttribute in interface Attributesname - attribute - public void clearAttributes()
clearAttributes in interface Attributespublic HttpDestination getDestination(Address remote, boolean ssl) throws IOException
IOExceptionpublic HttpDestination getDestination(Address remote, boolean ssl, SslContextFactory sslContextFactory) throws IOException
IOExceptionpublic Collection<Address> getDestinations()
public void removeDestination(HttpDestination destination)
public void schedule(Timeout.Task task)
public void schedule(Timeout.Task task, long timeout)
public void scheduleIdle(Timeout.Task task)
public void cancel(Timeout.Task task)
public boolean getUseDirectBuffers()
public void setRealmResolver(RealmResolver resolver)
SecurityListener so that
BASIC and DIGEST authentication can be performed.resolver - public RealmResolver getRealmResolver()
public boolean hasRealms()
public void registerListener(String listenerClass)
listenerClass - public LinkedList<String> getRegisteredListeners()
public void setUseDirectBuffers(boolean direct)
direct - If True (the default), the connector can use NIO direct
buffers. Some JVMs have memory management issues (bugs) with
direct buffers.public int getConnectorType()
public void setConnectorType(int connectorType)
public int getMaxConnectionsPerAddress()
public void setMaxConnectionsPerAddress(int maxConnectionsPerAddress)
public int getMaxQueueSizePerAddress()
public void setMaxQueueSizePerAddress(int maxQueueSizePerAddress)
protected void doStart()
throws Exception
AggregateLifeCycledoStart in class AggregateLifeCycleExceptionAbstractLifeCycle.doStart()protected void doStop()
throws Exception
AggregateLifeCycledoStop in class AggregateLifeCycleExceptionAbstractLifeCycle.doStart()protected SSLContext getSSLContext()
public SslContextFactory getSslContextFactory()
public long getIdleTimeout()
AbstractHttpConnection can be idle for before it is closed.public void setIdleTimeout(long ms)
ms - the period in milliseconds a AbstractHttpConnection can be idle for before it is closed.@Deprecated public int getSoTimeout()
getTimeout() instead.@Deprecated public void setSoTimeout(int timeout)
setTimeout(long) instead.timeout - the period in ms that an exchange will wait for a response from the server.public long getTimeout()
public void setTimeout(long timeout)
timeout - the period in ms that an exchange will wait for a response from the server.public int getConnectTimeout()
public void setConnectTimeout(int connectTimeout)
connectTimeout - the period in ms before timing out an attempt to connectpublic Address getProxy()
public void setProxy(Address proxy)
public Authentication getProxyAuthentication()
public void setProxyAuthentication(Authentication authentication)
public boolean isProxied()
public int maxRetries()
public void setMaxRetries(int retries)
public int maxRedirects()
public void setMaxRedirects(int redirects)
public int getRequestBufferSize()
getRequestBufferSize in interface HttpBufferspublic void setRequestBufferSize(int requestBufferSize)
setRequestBufferSize in interface HttpBuffersrequestBufferSize - the requestBufferSize to setpublic int getRequestHeaderSize()
getRequestHeaderSize in interface HttpBufferspublic void setRequestHeaderSize(int requestHeaderSize)
setRequestHeaderSize in interface HttpBuffersrequestHeaderSize - the requestHeaderSize to setpublic int getResponseBufferSize()
getResponseBufferSize in interface HttpBufferspublic void setResponseBufferSize(int responseBufferSize)
setResponseBufferSize in interface HttpBuffersresponseBufferSize - the responseBufferSize to setpublic int getResponseHeaderSize()
getResponseHeaderSize in interface HttpBufferspublic void setResponseHeaderSize(int responseHeaderSize)
setResponseHeaderSize in interface HttpBuffersresponseHeaderSize - the responseHeaderSize to setpublic Buffers.Type getRequestBufferType()
getRequestBufferType in interface HttpBufferspublic Buffers.Type getRequestHeaderType()
getRequestHeaderType in interface HttpBufferspublic Buffers.Type getResponseBufferType()
getResponseBufferType in interface HttpBufferspublic Buffers.Type getResponseHeaderType()
getResponseHeaderType in interface HttpBufferspublic void setRequestBuffers(Buffers requestBuffers)
setRequestBuffers in interface HttpBuffersrequestBuffers - the requestBuffers to setpublic void setResponseBuffers(Buffers responseBuffers)
setResponseBuffers in interface HttpBuffersresponseBuffers - the responseBuffers to setpublic Buffers getRequestBuffers()
getRequestBuffers in interface HttpBufferspublic Buffers getResponseBuffers()
getResponseBuffers in interface HttpBufferspublic void setMaxBuffers(int maxBuffers)
setMaxBuffers in interface HttpBufferspublic int getMaxBuffers()
getMaxBuffers in interface HttpBuffers@Deprecated public String getTrustStoreLocation()
@Deprecated public void setTrustStoreLocation(String trustStoreLocation)
@Deprecated public InputStream getTrustStoreInputStream()
@Deprecated public void setTrustStoreInputStream(InputStream trustStoreInputStream)
@Deprecated public String getKeyStoreLocation()
@Deprecated public void setKeyStoreLocation(String keyStoreLocation)
@Deprecated public InputStream getKeyStoreInputStream()
@Deprecated public void setKeyStoreInputStream(InputStream keyStoreInputStream)
@Deprecated public void setKeyStorePassword(String keyStorePassword)
@Deprecated public void setKeyManagerPassword(String keyManagerPassword)
@Deprecated public void setTrustStorePassword(String trustStorePassword)
@Deprecated public String getKeyStoreType()
@Deprecated public void setKeyStoreType(String keyStoreType)
@Deprecated public String getTrustStoreType()
@Deprecated public void setTrustStoreType(String trustStoreType)
@Deprecated public String getKeyManagerAlgorithm()
@Deprecated public void setKeyManagerAlgorithm(String keyManagerAlgorithm)
@Deprecated public String getTrustManagerAlgorithm()
@Deprecated public void setTrustManagerAlgorithm(String trustManagerAlgorithm)
@Deprecated public String getProtocol()
@Deprecated public void setProtocol(String protocol)
@Deprecated public String getProvider()
@Deprecated public void setProvider(String provider)
@Deprecated public String getSecureRandomAlgorithm()
@Deprecated public void setSecureRandomAlgorithm(String secureRandomAlgorithm)
Copyright © 1995-2015 Mort Bay Consulting. All Rights Reserved.