|
|||||||||
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(INonBlockingConnection connection)
constructor |
|
HttpClientConnection(String host,
int port)
constructor |
|
HttpClientConnection(String host,
int port,
IHttpConnectionHandler connectionHandler)
constructor |
Method Summary | |
---|---|
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 occurspublic 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 occurspublic HttpClientConnection(INonBlockingConnection connection) throws IOException
connection
- the underlying tcp connection
IOException
- if an exception occurspublic 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 occursMethod Detail |
---|
protected static boolean isComplete(NonBlockingBodyDataSource body)
protected static boolean isNetworkendpoint(NonBlockingBodyDataSource dataSource)
protected static boolean isSupports100Contine(IHttpResponseHandler handler)
protected static void forward(NonBlockingBodyDataSource dataSource, BodyDataSink dataSink) throws IOException
IOException
protected static int getDataReceived(NonBlockingBodyDataSource dataSource)
protected static BodyDataSink newInMemoryBodyDataSink(String id, IHttpMessageHeader header) throws IOException
IOException
protected 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 Closeable
close
in class org.xlightweb.AbstractHttpConnection
IOException
protected void onIdleTimeout()
onIdleTimeout
in class org.xlightweb.AbstractHttpConnection
protected void onConnectionTimeout()
onConnectionTimeout
in class org.xlightweb.AbstractHttpConnection
protected 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 periodpublic IHttpResponse call(IHttpRequest request) throws IOException, ConnectException, SocketTimeoutException
call
in interface IHttpClientEndpoint
request
- 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.AbstractHttpConnection
public boolean isServerSide()
isServerSide
in interface IConnection
public void setResponseBodyDefaultEncoding(String defaultEncoding)
encoding
- the defaultEncodingpublic void setResponseTimeoutMillis(long responseTimeoutMillis)
setResponseTimeoutMillis
in interface IHttpClientEndpoint
responseTimeoutMillis
- the response timeoutpublic long getResponseTimeoutMillis()
getResponseTimeoutMillis
in interface IHttpClientEndpoint
public BodyDataSink send(IHttpRequestHeader requestHeader, IHttpResponseHandler responseHandler) throws IOException, ConnectException
send
in interface IHttpClientEndpoint
requestHeader
- 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 occurspublic BodyDataSink send(IHttpRequestHeader requestHeader, int contentLength, IHttpResponseHandler responseHandler) throws IOException, ConnectException
send
in interface IHttpClientEndpoint
requestHeader
- 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 occurspublic IFutureResponse send(IHttpRequest request) throws IOException, ConnectException
send
in interface IHttpClientEndpoint
request
- the request
ConnectException
- if an error occurred while attempting to connect to a remote address and port.
IOException
- if an exception occurspublic void send(IHttpRequest request, IHttpResponseHandler responseHandler) throws IOException, ConnectException
send
in interface IHttpClientEndpoint
request
- 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.AbstractHttpConnection
protected 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 |