Class Connection
java.lang.Object
com.predic8.membrane.core.transport.http.Connection
- All Implemented Interfaces:
MessageObserver,NonRelevantBodyObserver,Closeable,AutoCloseable
public class Connection
extends Object
implements Closeable, MessageObserver, NonRelevantBodyObserver
A
Connection is an outbound TCP/IP connection, possibly managed
by a ConnectionManager.
It is symbiotic to an Exchange during the exchange's HTTP client
call, which starts in HttpClient.call(Exchange) and ends when the
HTTP response body has fully been read (or never, if
Request.isBindTargetConnectionToIncoming() is true).
The connection will be registered by the HttpClient as a
MessageObserver on the Response to get notified when the HTTP
response body has fully been read and it should deassociate itself from the
exchange.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidbodyChunk(byte[] buffer, int offset, int length) Observes a piece of the body.voidObserves a piece of the body.voidbodyComplete(AbstractBody body) Notification that the body has fully been received.voidbodyRequested(AbstractBody body) voidclose()protected voidfinalize()String[]final intgetHost()final longfinal intfinal longbooleanisClosed()booleanstatic Connectionopen(String host, int port, String localHost, SSLProvider sslProvider, int connectTimeout) static Connectionopen(String host, int port, String localHost, SSLProvider sslProvider, ConnectionManager mgr, int connectTimeout) static Connectionopen(String host, int port, String localHost, SSLProvider sslProvider, ConnectionManager mgr, int connectTimeout, String sniServername, ProxyConfiguration proxy, SSLProvider proxySSLProvider, String[] applicationProtocols) voidrelease()SeeConnectionManagerfor documentation.final voidsetMaxExchanges(int maxExchanges) final voidsetTimeout(long timeout) toString()
-
Field Details
-
mgr
-
host
-
socket
-
in
-
out
-
-
Method Details
-
open
public static Connection open(String host, int port, String localHost, SSLProvider sslProvider, int connectTimeout) throws UnknownHostException, IOException - Throws:
UnknownHostExceptionIOException
-
open
public static Connection open(String host, int port, String localHost, SSLProvider sslProvider, ConnectionManager mgr, int connectTimeout, @Nullable String sniServername, @Nullable ProxyConfiguration proxy, @Nullable SSLProvider proxySSLProvider, @Nullable String[] applicationProtocols) throws UnknownHostException, IOException - Throws:
UnknownHostExceptionIOException
-
open
public static Connection open(String host, int port, String localHost, SSLProvider sslProvider, ConnectionManager mgr, int connectTimeout) throws UnknownHostException, IOException - Throws:
UnknownHostExceptionIOException
-
isSame
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
finalize
-
isClosed
public boolean isClosed() -
release
SeeConnectionManagerfor documentation.- Throws:
IOException
-
bodyChunk
Description copied from interface:MessageObserverObserves a piece of the body.- Specified by:
bodyChunkin interfaceMessageObserver
-
bodyChunk
public void bodyChunk(byte[] buffer, int offset, int length) Description copied from interface:MessageObserverObserves a piece of the body. Note that the buffer content may change after the method completes.- Specified by:
bodyChunkin interfaceMessageObserver
-
bodyRequested
- Specified by:
bodyRequestedin interfaceMessageObserver
-
bodyComplete
Description copied from interface:MessageObserverNotification that the body has fully been received.Note that this event may run instantaneously (during the call to
Message.addObserver(MessageObserver)), as the body may have already been fully received when registering the observer.This is the last event that will be fired on any MessageObserver.
- Specified by:
bodyCompletein interfaceMessageObserver
-
setTimeout
public final void setTimeout(long timeout) -
getTimeout
public final long getTimeout() -
getMaxExchanges
public final int getMaxExchanges() -
setMaxExchanges
public final void setMaxExchanges(int maxExchanges) -
getCompletedExchanges
public final int getCompletedExchanges() -
getLastUse
public final long getLastUse() -
getHost
-
toString
-
getSniServerName
-
getProxyConfiguration
-
getProxySSLProvider
-
getSslProvider
-
getApplicationProtocols
-