|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

java.lang.Objectorg.xlightweb.AbstractHttpConnection
org.xlightweb.client.HttpClientConnection
public final class HttpClientConnection
Represents the client side endpoint implementation of a http connection. The HttpClientConnection supports
constructors which accepts the remote address or a existing INonBlockingConnection. A INonBlockingConnection
can become a HttpClientConnection at any time.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.xlightweb.AbstractHttpConnection |
|---|
org.xlightweb.AbstractHttpConnection.AbstractExchange, org.xlightweb.AbstractHttpConnection.IMessageHandler, org.xlightweb.AbstractHttpConnection.IMessageHeaderHandler, org.xlightweb.AbstractHttpConnection.IMultimodeExecutor, org.xlightweb.AbstractHttpConnection.RequestHandlerAdapter, org.xlightweb.AbstractHttpConnection.ResponseHandlerAdapter |
| Nested classes/interfaces inherited from interface org.xsocket.connection.IConnection |
|---|
IConnection.FlushMode |
| Field Summary |
|---|
| Fields inherited from interface org.xlightweb.client.IHttpClientEndpoint |
|---|
DEFAULT_AUTOHANDLE_100CONTINUE_RESPONSE |
| Fields inherited from interface org.xlightweb.IHttpConnection |
|---|
DEFAULT_CONNECT_TIMEOUT_MILLIS, DEFAULT_DATA_RESPONSE_TIMEOUT_MILLIS, DEFAULT_RESPONSE_TIMEOUT_MILLIS |
| Fields inherited from interface org.xsocket.connection.IConnection |
|---|
DEFAULT_AUTOFLUSH, DEFAULT_CONNECTION_TIMEOUT_MILLIS, DEFAULT_FLUSH_MODE, DEFAULT_IDLE_TIMEOUT_MILLIS, INITIAL_DEFAULT_ENCODING, MAX_TIMEOUT_MILLIS, SO_KEEPALIVE, SO_LINGER, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF, SO_TIMEOUT, TCP_NODELAY |
| Constructor Summary | |
|---|---|
HttpClientConnection(InetSocketAddress address)
constructor |
|
HttpClientConnection(InetSocketAddress address,
Executor workerpool)
constructor |
|
HttpClientConnection(INonBlockingConnection connection)
constructor |
|
HttpClientConnection(String host,
int port)
constructor |
|
HttpClientConnection(String host,
int port,
Executor workerpool)
constructor |
|
HttpClientConnection(String host,
int port,
Executor workerpool,
IHttpConnectionHandler connectionHandler)
constructor |
|
HttpClientConnection(String host,
int port,
IHttpConnectionHandler connectionHandler)
constructor |
|
| Method Summary | |
|---|---|
protected static void |
addConnectionAttribute(IHttpResponseHeader header,
IHttpConnection con)
|
protected static int |
availableSilence(NonBlockingBodyDataSource dataSource)
|
IHttpResponse |
call(IHttpRequest request)
performs a request. |
void |
close()
|
protected static void |
forward(NonBlockingBodyDataSource dataSource,
BodyDataSink dataSink)
|
protected static String |
generateErrorMessageHtml(int errorCode,
String msg,
String id)
generates a error page |
protected static IBodyDataHandler |
getDataHandlerSilence(NonBlockingBodyDataSource dataSource)
|
protected static int |
getDataReceived(NonBlockingBodyDataSource dataSource)
|
protected static NonBlockingBodyDataSource |
getDataSourceOfInMemoryBodyDataSink(BodyDataSink dataSink)
|
protected org.xlightweb.AbstractHttpConnection.IMessageHeaderHandler |
getMessageHeaderHandler()
|
protected static IHeader |
getReceivedHeader(ProtocolException pe)
|
long |
getResponseTimeoutMillis()
returns the response timeout |
protected static boolean |
isComplete(NonBlockingBodyDataSource body)
|
protected static boolean |
isNetworkendpoint(NonBlockingBodyDataSource dataSource)
|
boolean |
isServerSide()
|
protected static boolean |
isSupports100Contine(IHttpResponseHandler handler)
|
protected static BodyDataSink |
newInMemoryBodyDataSink(String id,
IHttpMessageHeader header)
|
protected void |
onConnectionTimeout()
|
protected void |
onDisconnect()
|
protected void |
onIdleTimeout()
|
protected void |
onMessageCompleteReceived(IHttpMessageHeader header)
|
protected static ByteBuffer[] |
readByteBufferByLengthSilence(NonBlockingBodyDataSource dataSource,
int length)
|
protected void |
removeMessageHandler(org.xlightweb.AbstractHttpConnection.IMessageHeaderHandler messageHandler)
|
protected static void |
schedule(TimerTask task,
long delay,
long period)
schedules a timer task |
IFutureResponse |
send(IHttpRequest request)
send the request. |
BodyDataSink |
send(IHttpRequestHeader requestHeader,
IHttpResponseHandler responseHandler)
send the request. |
BodyDataSink |
send(IHttpRequestHeader requestHeader,
int contentLength,
IHttpResponseHandler responseHandler)
send the request in a plain body mode Connection-LifeCycle support: If the request header contains a 'Connection: close' entry, the connection will be closed after the HTTP transaction |
void |
send(IHttpRequest request,
IHttpResponseHandler responseHandler)
send the request. |
protected static void |
setDataHandlerSilence(NonBlockingBodyDataSource dataSource,
IBodyDataHandler dataHandler)
|
void |
setResponseBodyDefaultEncoding(String defaultEncoding)
set the response body default encoding. |
void |
setResponseTimeoutMillis(long responseTimeoutMillis)
set the response time out by performing the call or send method. |
String |
toString()
|
| Methods inherited from class org.xlightweb.AbstractHttpConnection |
|---|
activateSecuredMode, addConnectionHandler, closeQuitly, destroy, destroy, destroy, destroy, forwardBody, getAttachment, getBodyDataReceiveTimeoutMillis, getConnectionTimeoutMillis, getCountMessagesReceived, getCountMessagesSent, getCountReceivedBytes, getExecutor, getId, getIdleTimeoutMillis, getLastTimeDataReceivedMillis, getLastTimeHeaderReceivedMillis, getLastTimeMessageTailReceivedMillis, getLastTimeWritten, getLocalAddress, getLocalPort, getMaxWriteBufferSize, getNumOpenTransactions, getOption, getOptions, getReceviedHeader, getRemainingMillisToConnectionTimeout, getRemainingMillisToIdleTimeout, getRemoteAddress, getRemotePort, getSizeDataReceived, getSizeWritten, getUnderlyingTcpConnection, getWorkerpool, incCountMessageReceived, incCountMessageSent, init, isAcceptingChunkedResponseBody, isAutoUncompress, isContentTypeSupportsCharset, isEmpty, isForwardable, isOpen, isPersistent, isReceivingSuspended, isReuseable, isSecure, newDetailedClosedChannelException, newDoNothingResponseHandler, newEmtpyBodyDataSink, newFormEncodedRequestWrapper, newMultimodeExecutor, onConnect, onMessageWritten, onProtocolException, parseEncoding, removeConnectionHandler, resumeReceiving, schedule, setAttachment, setAutocompressThreshold, setAutoUncompress, setBodyCloseListener, setBodyDataReceiveTimeoutMillis, setBodyDefaultEncoding, setConnectionTimeoutMillis, setIdleTimeoutMillis, setLastTimeDataReceivedMillis, setLastTimeHeaderReceivedMillis, setLastTimeMessageTailReceivedMillis, setNetworkBodyDataSinkIgnoreWriteError, setOption, setPersistent, setWorkerpool, setWriteTransferRate, suspendReceiving, writeMessage, writeMessage, writeMessage, writeMessageSilence |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.xlightweb.client.IHttpClientEndpoint |
|---|
getId |
| Constructor Detail |
|---|
public HttpClientConnection(String host,
int port)
throws IOException,
ConnectException
host - the remote hostport - the remote port
ConnectException - if an error occurred while attempting to connect to a remote address and port.
IOException - if an exception occurs
public HttpClientConnection(String host,
int port,
Executor workerpool)
throws IOException,
ConnectException
host - the remote hostport - the remote portworkerpool - the workerpool to use
ConnectException - if an error occurred while attempting to connect to a remote address and port.
IOException - if an exception occurs
public HttpClientConnection(InetSocketAddress address)
throws IOException,
ConnectException
address - the server address
ConnectException - if an error occurred while attempting to connect to a remote address and port.
IOException - if an exception occurs
public HttpClientConnection(InetSocketAddress address,
Executor workerpool)
throws IOException,
ConnectException
address - the server addressworkerpool - the workerpool to use
ConnectException - if an error occurred while attempting to connect to a remote address and port.
IOException - if an exception occurs
public HttpClientConnection(INonBlockingConnection connection)
throws IOException
connection - the underlying tcp connection
IOException - if an exception occurs
public HttpClientConnection(String host,
int port,
IHttpConnectionHandler connectionHandler)
throws IOException,
ConnectException
host - the remote hostport - the remote portconnectionHandler - the connection handler
ConnectException - if an error occurred while attempting to connect to a remote address and port.
IOException - if an exception occurs
public HttpClientConnection(String host,
int port,
Executor workerpool,
IHttpConnectionHandler connectionHandler)
throws IOException,
ConnectException
host - the remote hostport - the remote portworkerpool - the workerpool to useconnectionHandler - the connection handler
ConnectException - if an error occurred while attempting to connect to a remote address and port.
IOException - if an exception occurs| Method Detail |
|---|
protected static boolean isComplete(NonBlockingBodyDataSource body)
protected static boolean isNetworkendpoint(NonBlockingBodyDataSource dataSource)
protected static void addConnectionAttribute(IHttpResponseHeader header,
IHttpConnection con)
protected static boolean isSupports100Contine(IHttpResponseHandler handler)
protected static void forward(NonBlockingBodyDataSource dataSource,
BodyDataSink dataSink)
throws IOException
IOExceptionprotected static int getDataReceived(NonBlockingBodyDataSource dataSource)
protected static BodyDataSink newInMemoryBodyDataSink(String id,
IHttpMessageHeader header)
throws IOException
IOExceptionprotected static IHeader getReceivedHeader(ProtocolException pe)
protected static NonBlockingBodyDataSource getDataSourceOfInMemoryBodyDataSink(BodyDataSink dataSink)
protected static void setDataHandlerSilence(NonBlockingBodyDataSource dataSource,
IBodyDataHandler dataHandler)
protected static IBodyDataHandler getDataHandlerSilence(NonBlockingBodyDataSource dataSource)
protected static int availableSilence(NonBlockingBodyDataSource dataSource)
throws IOException
IOException
protected static ByteBuffer[] readByteBufferByLengthSilence(NonBlockingBodyDataSource dataSource,
int length)
throws IOException
IOException
public void close()
throws IOException
close in interface Closeableclose in class org.xlightweb.AbstractHttpConnectionIOExceptionprotected void onIdleTimeout()
onIdleTimeout in class org.xlightweb.AbstractHttpConnectionprotected void onConnectionTimeout()
onConnectionTimeout in class org.xlightweb.AbstractHttpConnectionprotected void onDisconnect()
onDisconnect in class org.xlightweb.AbstractHttpConnection
protected static String generateErrorMessageHtml(int errorCode,
String msg,
String id)
errorCode - the error codemsg - the messageid - the connection id
protected static void schedule(TimerTask task,
long delay,
long period)
task - the timer taskdelay - the delayperiod - the period
public IHttpResponse call(IHttpRequest request)
throws IOException,
ConnectException,
SocketTimeoutException
call in interface IHttpClientEndpointrequest - the request
IOException - if an exception occurs
ConnectException - if an error occurred while attempting to connect to a remote address and port.
SocketTimeoutException - if the received timeout is exceedprotected void onMessageCompleteReceived(IHttpMessageHeader header)
onMessageCompleteReceived in class org.xlightweb.AbstractHttpConnectionpublic boolean isServerSide()
isServerSide in interface IConnectionpublic void setResponseBodyDefaultEncoding(String defaultEncoding)
encoding - the defaultEncodingpublic void setResponseTimeoutMillis(long responseTimeoutMillis)
setResponseTimeoutMillis in interface IHttpClientEndpointresponseTimeoutMillis - the response timeoutpublic long getResponseTimeoutMillis()
getResponseTimeoutMillis in interface IHttpClientEndpoint
public BodyDataSink send(IHttpRequestHeader requestHeader,
IHttpResponseHandler responseHandler)
throws IOException,
ConnectException
send in interface IHttpClientEndpointrequestHeader - the request headerresponseHandler - the response handler or null (supported: IHttpRequestHandler, IHttpSocketTimeoutHandler)
ConnectException - if an error occurred while attempting to connect to a remote address and port.
IOException - if an exception occurs
public BodyDataSink send(IHttpRequestHeader requestHeader,
int contentLength,
IHttpResponseHandler responseHandler)
throws IOException,
ConnectException
send in interface IHttpClientEndpointrequestHeader - the request headercontentLength - the content lengthresponseHandler - the response handler or null (supported: IHttpRequestHandler, IHttpSocketTimeoutHandler)
ConnectException - if an error occurred while attempting to connect to a remote address and port.
IOException - if an exception occurs
public IFutureResponse send(IHttpRequest request)
throws IOException,
ConnectException
send in interface IHttpClientEndpointrequest - the request
ConnectException - if an error occurred while attempting to connect to a remote address and port.
IOException - if an exception occurs
public void send(IHttpRequest request,
IHttpResponseHandler responseHandler)
throws IOException,
ConnectException
send in interface IHttpClientEndpointrequest - the requestresponseHandler - the response handler or null (supported: IHttpRequestHandler, IHttpSocketTimeoutHandler)
ConnectException - if an error occurred while attempting to connect to a remote address and port.
IOException - if an exception occursprotected org.xlightweb.AbstractHttpConnection.IMessageHeaderHandler getMessageHeaderHandler()
getMessageHeaderHandler in class org.xlightweb.AbstractHttpConnectionprotected void removeMessageHandler(org.xlightweb.AbstractHttpConnection.IMessageHeaderHandler messageHandler)
public String toString()
toString in class org.xlightweb.AbstractHttpConnection
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||