java.lang.Runnable, HttpOutput.InterceptorHttpChannelOverHttppublic class HttpChannel extends java.lang.Object implements java.lang.Runnable, HttpOutput.Interceptor
| Modifier and Type | Class | Description |
|---|---|---|
static interface |
HttpChannel.Listener |
Listener for
HttpChannel events. |
| Constructor | Description |
|---|---|
HttpChannel(Connector connector,
HttpConfiguration configuration,
EndPoint endPoint,
HttpTransport transport) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
abort(java.lang.Throwable failure) |
If a write or similar operation to this channel fails,
then this method should be called.
|
void |
addRequestLog(RequestLog requestLog) |
|
protected void |
commit(MetaData.Response info) |
|
void |
continue100(int available) |
If the associated response has the Expect header set to 100 Continue,
then accessing the input stream indicates that the handler/servlet
is ready for the request body and thus a 100 Continue response is sent.
|
protected void |
execute(java.lang.Runnable task) |
|
ByteBufferPool |
getByteBufferPool() |
|
long |
getBytesWritten() |
|
MetaData.Response |
getCommittedMetaData() |
|
Connector |
getConnector() |
|
EndPoint |
getEndPoint() |
|
HttpConfiguration |
getHttpConfiguration() |
|
HttpTransport |
getHttpTransport() |
|
long |
getIdleTimeout() |
Get the idle timeout.
|
java.net.InetSocketAddress |
getLocalAddress() |
|
HttpOutput.Interceptor |
getNextInterceptor() |
|
java.net.InetSocketAddress |
getRemoteAddress() |
|
Request |
getRequest() |
|
RequestLog |
getRequestLog() |
|
long |
getRequests() |
|
Response |
getResponse() |
|
Scheduler |
getScheduler() |
|
Server |
getServer() |
|
HttpChannelState |
getState() |
|
boolean |
handle() |
|
protected void |
handleException(java.lang.Throwable failure) |
Sends an error 500, performing a special logic to detect whether the request is suspended,
to avoid concurrent writes from the application.
|
boolean |
isCommitted() |
|
boolean |
isExpecting100Continue() |
|
boolean |
isExpecting102Processing() |
|
boolean |
isOptimizedForDirectBuffers() |
|
protected HttpInput |
newHttpInput(HttpChannelState state) |
|
protected HttpOutput |
newHttpOutput() |
|
void |
onAsyncWaitForContent() |
|
void |
onBadMessage(BadMessageException failure) |
|
void |
onBlockWaitForContent() |
|
void |
onBlockWaitForContentFailure(java.lang.Throwable failure) |
|
void |
onCompleted() |
|
boolean |
onContent(HttpInput.Content content) |
|
boolean |
onContentComplete() |
|
boolean |
onEarlyEOF() |
|
void |
onRequest(MetaData.Request request) |
|
boolean |
onRequestComplete() |
|
void |
onTrailers(HttpFields trailers) |
|
void |
recycle() |
|
void |
resetBuffer() |
Reset the buffers.
|
void |
run() |
|
protected void |
sendError(int code,
java.lang.String reason) |
|
boolean |
sendResponse(MetaData.Response info,
java.nio.ByteBuffer content,
boolean complete) |
|
protected boolean |
sendResponse(MetaData.Response info,
java.nio.ByteBuffer content,
boolean complete,
Callback callback) |
|
void |
setIdleTimeout(long timeoutMs) |
Set the idle timeout.
|
void |
setRequestLog(RequestLog requestLog) |
|
java.lang.String |
toString() |
|
boolean |
useDirectBuffers() |
|
void |
write(java.nio.ByteBuffer content,
boolean complete,
Callback callback) |
Non-Blocking write, committing the response if needed.
|
public HttpChannel(Connector connector, HttpConfiguration configuration, EndPoint endPoint, HttpTransport transport)
protected HttpInput newHttpInput(HttpChannelState state)
protected HttpOutput newHttpOutput()
public HttpChannelState getState()
public long getBytesWritten()
public long getRequests()
public Connector getConnector()
public HttpTransport getHttpTransport()
public RequestLog getRequestLog()
public void setRequestLog(RequestLog requestLog)
public void addRequestLog(RequestLog requestLog)
public MetaData.Response getCommittedMetaData()
public long getIdleTimeout()
This is implemented as a call to EndPoint.getIdleTimeout(), but may be
overridden by channels that have timeouts different from their connections.
public void setIdleTimeout(long timeoutMs)
This is implemented as a call to EndPoint.setIdleTimeout(long), but may be
overridden by channels that have timeouts different from their connections.
timeoutMs - the idle timeout in millisecondspublic ByteBufferPool getByteBufferPool()
public HttpConfiguration getHttpConfiguration()
public boolean isOptimizedForDirectBuffers()
isOptimizedForDirectBuffers in interface HttpOutput.InterceptorByteBuffers in the HttpOutput.Interceptor.write(ByteBuffer, boolean, Callback)
method. If false is returned, then passing direct buffers may cause
inefficiencies.public Server getServer()
public Request getRequest()
public Response getResponse()
public EndPoint getEndPoint()
public java.net.InetSocketAddress getLocalAddress()
public java.net.InetSocketAddress getRemoteAddress()
public void continue100(int available)
throws java.io.IOException
available - estimate of the number of bytes that are availablejava.io.IOException - if the InputStream cannot be createdpublic void recycle()
public void onAsyncWaitForContent()
public void onBlockWaitForContent()
public void onBlockWaitForContentFailure(java.lang.Throwable failure)
public void run()
run in interface java.lang.Runnablepublic boolean handle()
protected void sendError(int code,
java.lang.String reason)
protected void handleException(java.lang.Throwable failure)
Sends an error 500, performing a special logic to detect whether the request is suspended, to avoid concurrent writes from the application.
It may happen that the application suspends, and then throws an exception, while an application
spawned thread writes the response content; in such case, we attempt to commit the error directly
bypassing the ErrorHandler mechanisms and the response OutputStream.
failure - the Throwable that caused the problempublic boolean isExpecting100Continue()
public boolean isExpecting102Processing()
public java.lang.String toString()
toString in class java.lang.Objectpublic void onRequest(MetaData.Request request)
public boolean onContent(HttpInput.Content content)
public boolean onContentComplete()
public void onTrailers(HttpFields trailers)
public boolean onRequestComplete()
public void onCompleted()
public boolean onEarlyEOF()
public void onBadMessage(BadMessageException failure)
protected boolean sendResponse(MetaData.Response info, java.nio.ByteBuffer content, boolean complete, Callback callback)
public boolean sendResponse(MetaData.Response info, java.nio.ByteBuffer content, boolean complete) throws java.io.IOException
java.io.IOExceptionprotected void commit(MetaData.Response info)
public boolean isCommitted()
public void write(java.nio.ByteBuffer content,
boolean complete,
Callback callback)
Non-Blocking write, committing the response if needed.
Called as last link in HttpOutput.Filter chainwrite in interface HttpOutput.Interceptorcontent - the content buffer to writecomplete - whether the content is complete for the responsecallback - Callback when complete or failedpublic void resetBuffer()
HttpOutput.InterceptorIf the Interceptor contains buffers then reset them.
resetBuffer in interface HttpOutput.Interceptorpublic HttpOutput.Interceptor getNextInterceptor()
getNextInterceptor in interface HttpOutput.Interceptorprotected void execute(java.lang.Runnable task)
public Scheduler getScheduler()
public boolean useDirectBuffers()
public void abort(java.lang.Throwable failure)
The standard implementation calls HttpTransport.abort(Throwable).
failure - the failure that caused the abort.Copyright © 1995–2018 Webtide. All rights reserved.