|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.http.HttpBuffers
org.eclipse.jetty.client.HttpClient
public class HttpClient
Http Client.
HttpClient is the main active component of the client API implementation. It is the opposite of the Connectors in standard Jetty, in that it listens for responses rather than requests. Just like the connectors, there is a blocking socket version and a non-blocking NIO version (implemented as nested classes selected bysetConnectorType(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 HttpConnection
s 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
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
---|
AbstractLifeCycle.AbstractLifeCycleListener |
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle |
---|
LifeCycle.Listener |
Field Summary | |
---|---|
static int |
CONNECTOR_SELECT_CHANNEL
|
static int |
CONNECTOR_SOCKET
|
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
---|
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING |
Constructor Summary | |
---|---|
HttpClient()
|
Method Summary | |
---|---|
void |
cancel(Timeout.Task task)
|
void |
clearAttributes()
|
protected void |
doStart()
|
protected void |
doStop()
|
void |
dump()
|
java.lang.Object |
getAttribute(java.lang.String name)
|
java.util.Enumeration |
getAttributeNames()
|
int |
getConnectorType()
Get the type of connector (socket, blocking or select) in use. |
int |
getConnectTimeout()
|
HttpDestination |
getDestination(Address remote,
boolean ssl)
|
long |
getIdleTimeout()
|
java.lang.String |
getKeyStoreLocation()
|
java.lang.String |
getKeyStoreType()
|
protected javax.net.ssl.SSLContext |
getLooseSSLContext()
|
int |
getMaxConnectionsPerAddress()
|
java.util.Set<java.lang.String> |
getNoProxy()
|
Address |
getProxy()
|
Authentication |
getProxyAuthentication()
|
RealmResolver |
getRealmResolver()
returns the SecurityRealmResolver reg_realmResolveristered with the HttpClient or null |
java.util.LinkedList<java.lang.String> |
getRegisteredListeners()
|
int |
getSoTimeout()
Deprecated. use getTimeout() instead. |
protected javax.net.ssl.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 javax.net.ssl.SSLContext |
getStrictSSLContext()
|
ThreadPool |
getThreadPool()
|
long |
getTimeout()
|
java.lang.String |
getTrustStoreLocation()
|
java.lang.String |
getTrustStoreType()
|
boolean |
getUseDirectBuffers()
Get whether the connector can use direct NIO buffers. |
boolean |
hasRealms()
|
boolean |
isProxied()
|
protected boolean |
isRequestHeader(Buffer buffer)
|
protected boolean |
isResponseHeader(Buffer buffer)
|
int |
maxRedirects()
|
int |
maxRetries()
|
protected Buffer |
newRequestBuffer(int size)
|
protected Buffer |
newRequestHeader(int size)
|
protected Buffer |
newResponseBuffer(int size)
|
protected Buffer |
newResponseHeader(int size)
|
void |
registerListener(java.lang.String listenerClass)
Registers a listener that can listen to the stream of execution between the client and the server and influence events. |
void |
removeAttribute(java.lang.String name)
|
void |
schedule(Timeout.Task task)
|
void |
scheduleIdle(Timeout.Task task)
|
void |
send(HttpExchange exchange)
|
void |
setAttribute(java.lang.String name,
java.lang.Object attribute)
Set an attribute on the HttpClient. |
void |
setConnectorType(int connectorType)
|
void |
setConnectTimeout(int connectTimeout)
|
void |
setIdleTimeout(long ms)
|
void |
setKeyManagerPassword(java.lang.String keyManagerPassword)
|
void |
setKeyStoreLocation(java.lang.String keyStoreLocation)
|
void |
setKeyStorePassword(java.lang.String keyStorePassword)
|
void |
setKeyStoreType(java.lang.String keyStoreType)
|
void |
setMaxConnectionsPerAddress(int maxConnectionsPerAddress)
|
void |
setMaxRedirects(int redirects)
|
void |
setMaxRetries(int retries)
|
void |
setNoProxy(java.util.Set<java.lang.String> noProxyAddresses)
|
void |
setProxy(Address proxy)
|
void |
setProxyAuthentication(Authentication authentication)
|
void |
setRealmResolver(RealmResolver resolver)
Set a RealmResolver for client Authentication. |
void |
setSoTimeout(int timeout)
Deprecated. use setTimeout(long) instead. |
void |
setThreadPool(ThreadPool threadPool)
|
void |
setTimeout(long timeout)
|
void |
setTrustStoreLocation(java.lang.String trustStoreLocation)
|
void |
setTrustStorePassword(java.lang.String trustStorePassword)
|
void |
setTrustStoreType(java.lang.String trustStoreType)
|
void |
setUseDirectBuffers(boolean direct)
Set to use NIO direct buffers. |
Methods inherited from class org.eclipse.jetty.http.HttpBuffers |
---|
getHeaderBufferSize, getRequestBuffers, getRequestBufferSize, getRequestHeaderSize, getResponseBuffers, getResponseBufferSize, getResponseHeaderSize, setHeaderBufferSize, setRequestBufferSize, setRequestHeaderSize, setResponseBufferSize, setResponseHeaderSize |
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
---|
addLifeCycleListener, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CONNECTOR_SOCKET
public static final int CONNECTOR_SELECT_CHANNEL
Constructor Detail |
---|
public HttpClient()
Method Detail |
---|
public void dump()
public void send(HttpExchange exchange) throws java.io.IOException
java.io.IOException
public ThreadPool getThreadPool()
public void setThreadPool(ThreadPool threadPool)
threadPool
- the threadPool to setpublic java.lang.Object getAttribute(java.lang.String name)
getAttribute
in interface Attributes
name
-
public java.util.Enumeration getAttributeNames()
getAttributeNames
in interface Attributes
public void removeAttribute(java.lang.String name)
removeAttribute
in interface Attributes
name
- public void setAttribute(java.lang.String name, java.lang.Object attribute)
setAttribute
in interface Attributes
name
- attribute
- public void clearAttributes()
clearAttributes
in interface Attributes
public HttpDestination getDestination(Address remote, boolean ssl) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public void schedule(Timeout.Task task)
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(java.lang.String listenerClass)
listenerClass
- public java.util.LinkedList<java.lang.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 Buffer newRequestBuffer(int size)
newRequestBuffer
in class HttpBuffers
HttpBuffers.newRequestBuffer(int)
protected Buffer newRequestHeader(int size)
newRequestHeader
in class HttpBuffers
HttpBuffers.newRequestHeader(int)
protected Buffer newResponseBuffer(int size)
newResponseBuffer
in class HttpBuffers
HttpBuffers.newResponseBuffer(int)
protected Buffer newResponseHeader(int size)
newResponseHeader
in class HttpBuffers
HttpBuffers.newResponseHeader(int)
protected boolean isRequestHeader(Buffer buffer)
isRequestHeader
in class HttpBuffers
protected boolean isResponseHeader(Buffer buffer)
isResponseHeader
in class HttpBuffers
public int getMaxConnectionsPerAddress()
public void setMaxConnectionsPerAddress(int maxConnectionsPerAddress)
protected void doStart() throws java.lang.Exception
doStart
in class HttpBuffers
java.lang.Exception
protected void doStop() throws java.lang.Exception
doStop
in class AbstractLifeCycle
java.lang.Exception
protected javax.net.ssl.SSLContext getSSLContext() throws java.io.IOException
java.io.IOException
protected javax.net.ssl.SSLContext getStrictSSLContext() throws java.io.IOException
java.io.IOException
protected javax.net.ssl.SSLContext getLooseSSLContext() throws java.io.IOException
java.io.IOException
public 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.@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 java.util.Set<java.lang.String> getNoProxy()
public void setNoProxy(java.util.Set<java.lang.String> noProxyAddresses)
public int maxRetries()
public void setMaxRetries(int retries)
public int maxRedirects()
public void setMaxRedirects(int redirects)
public java.lang.String getTrustStoreLocation()
public void setTrustStoreLocation(java.lang.String trustStoreLocation)
public java.lang.String getKeyStoreLocation()
public void setKeyStoreLocation(java.lang.String keyStoreLocation)
public void setKeyStorePassword(java.lang.String keyStorePassword)
public void setKeyManagerPassword(java.lang.String keyManagerPassword)
public void setTrustStorePassword(java.lang.String trustStorePassword)
public java.lang.String getKeyStoreType()
public void setKeyStoreType(java.lang.String keyStoreType)
public java.lang.String getTrustStoreType()
public void setTrustStoreType(java.lang.String trustStoreType)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |