public class HttpClient
extends org.mortbay.jetty.AbstractBuffers
implements org.mortbay.util.Attributes
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 HttpConnection,
queued in the HttpConnection waiting to be transmitted or pipelined on the actual
TCP/IP connection waiting for a response.
The HttpDestination class is an aggregation of HttpConnections 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},
HttpDestination}| Modifier and Type | Field and Description |
|---|---|
static int |
CONNECTOR_SELECT_CHANNEL |
static int |
CONNECTOR_SOCKET |
| Constructor and Description |
|---|
HttpClient() |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel(org.mortbay.thread.Timeout.Task task) |
void |
clearAttributes() |
protected void |
doStart() |
protected void |
doStop() |
void |
dump() |
Object |
getAttribute(String name) |
Enumeration |
getAttributeNames() |
int |
getConnectorType()
Get the type of connector (socket, blocking or select) in use.
|
HttpDestination |
getDestination(Address remote,
boolean ssl) |
long |
getIdleTimeout() |
String |
getKeyStoreLocation() |
protected SSLContext |
getLooseSSLContext() |
int |
getMaxConnectionsPerAddress() |
Set<String> |
getNoProxy() |
Address |
getProxy() |
Authorization |
getProxyAuthentication() |
RealmResolver |
getRealmResolver()
returns the SecurityRealmResolver registered with the HttpClient or null
|
LinkedList<String> |
getRegisteredListeners() |
int |
getSoTimeout() |
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.
|
protected SSLContext |
getStrictSSLContext() |
org.mortbay.thread.ThreadPool |
getThreadPool() |
long |
getTimeout() |
String |
getTrustStoreLocation() |
boolean |
getUseDirectBuffers()
Get whether the connector can use direct NIO buffers.
|
boolean |
hasRealms() |
boolean |
isProxied() |
int |
maxRetries() |
protected org.mortbay.io.Buffer |
newBuffer(int size)
Create a new NIO buffer.
|
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 |
schedule(org.mortbay.thread.Timeout.Task task) |
void |
schedule(org.mortbay.thread.Timeout.Task task,
long timeout) |
void |
scheduleIdle(org.mortbay.thread.Timeout.Task task) |
void |
send(HttpExchange exchange) |
void |
setAttribute(String name,
Object attribute)
Set an attribute on the HttpClient.
|
void |
setConnectorType(int connectorType) |
void |
setIdleTimeout(long ms) |
void |
setKeyManagerPassword(String _keyManagerPassword) |
void |
setKeyStoreLocation(String keyStoreLocation) |
void |
setKeyStorePassword(String _keyStorePassword) |
void |
setMaxConnectionsPerAddress(int maxConnectionsPerAddress) |
void |
setMaxRetries(int retries) |
void |
setNoProxy(Set<String> noProxyAddresses) |
void |
setProxy(Address proxy) |
void |
setProxyAuthentication(Authorization authentication) |
void |
setRealmResolver(RealmResolver resolver) |
void |
setSoTimeout(int so) |
void |
setThreadPool(org.mortbay.thread.ThreadPool threadPool) |
void |
setTimeout(long ms) |
void |
setTrustStoreLocation(String trustStoreLocation) |
void |
setTrustStorePassword(String _trustStorePassword) |
void |
setUseDirectBuffers(boolean direct)
Set to use NIO direct buffers.
|
getBuffer, getHeaderBufferSize, getRequestBufferSize, getResponseBufferSize, returnBuffer, setHeaderBufferSize, setRequestBufferSize, setResponseBufferSize, toStringpublic static final int CONNECTOR_SOCKET
public static final int CONNECTOR_SELECT_CHANNEL
public void dump()
throws IOException
IOExceptionpublic void send(HttpExchange exchange) throws IOException
IOExceptionpublic org.mortbay.thread.ThreadPool getThreadPool()
public void setThreadPool(org.mortbay.thread.ThreadPool threadPool)
threadPool - the threadPool to setpublic Object getAttribute(String name)
getAttribute in interface org.mortbay.util.Attributesname - public Enumeration getAttributeNames()
getAttributeNames in interface org.mortbay.util.Attributespublic void removeAttribute(String name)
removeAttribute in interface org.mortbay.util.Attributesname - public void setAttribute(String name, Object attribute)
setAttribute in interface org.mortbay.util.Attributesname - attribute - public void clearAttributes()
clearAttributes in interface org.mortbay.util.Attributesname - public HttpDestination getDestination(Address remote, boolean ssl) throws UnknownHostException, IOException
UnknownHostExceptionIOExceptionpublic void schedule(org.mortbay.thread.Timeout.Task task)
public void schedule(org.mortbay.thread.Timeout.Task task,
long timeout)
public void scheduleIdle(org.mortbay.thread.Timeout.Task task)
public void cancel(org.mortbay.thread.Timeout.Task task)
public boolean getUseDirectBuffers()
public void setRealmResolver(RealmResolver 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)
protected org.mortbay.io.Buffer newBuffer(int size)
newBuffer in class org.mortbay.jetty.AbstractBufferspublic int getMaxConnectionsPerAddress()
public void setMaxConnectionsPerAddress(int maxConnectionsPerAddress)
protected void doStart()
throws Exception
doStart in class org.mortbay.jetty.AbstractBuffersExceptionprotected void doStop()
throws Exception
doStop in class org.mortbay.component.AbstractLifeCycleExceptionprotected SSLContext getSSLContext() throws IOException
IOExceptionprotected SSLContext getStrictSSLContext() throws IOException
IOExceptionprotected SSLContext getLooseSSLContext() throws IOException
IOExceptionpublic long getIdleTimeout()
HttpConnection can be idle for before it is closed.public void setIdleTimeout(long ms)
ms - the period in milliseconds a HttpConnection can be idle for before it is closed.public int getSoTimeout()
public void setSoTimeout(int so)
public long getTimeout()
public void setTimeout(long ms)
ms - the period in ms that an exchange will wait for a response from the server.public Address getProxy()
public void setProxy(Address proxy)
public Authorization getProxyAuthentication()
public void setProxyAuthentication(Authorization authentication)
public boolean isProxied()
public int maxRetries()
public void setMaxRetries(int retries)
public String getTrustStoreLocation()
public void setTrustStoreLocation(String trustStoreLocation)
public String getKeyStoreLocation()
public void setKeyStoreLocation(String keyStoreLocation)
public void setKeyStorePassword(String _keyStorePassword)
public void setKeyManagerPassword(String _keyManagerPassword)
public void setTrustStorePassword(String _trustStorePassword)
Copyright © 2009 Mortbay Consulting Pty. Ltd. All Rights Reserved.