public class HttpChannel extends Object implements Runnable, HttpOutput.Interceptor
Constructor and Description |
---|
HttpChannel(Connector connector,
HttpConfiguration configuration,
EndPoint endPoint,
HttpTransport transport) |
Modifier and Type | Method and Description |
---|---|
void |
abort(Throwable failure)
If a write or similar operation to this channel fails,
then this method should be called.
|
void |
addRequestLog(RequestLog requestLog) |
void |
asyncReadFillInterested() |
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(Runnable task) |
ByteBufferPool |
getByteBufferPool() |
long |
getBytesWritten() |
MetaData.Response |
getCommittedMetaData() |
Connector |
getConnector() |
EndPoint |
getEndPoint() |
HttpConfiguration |
getHttpConfiguration() |
HttpTransport |
getHttpTransport() |
long |
getIdleTimeout()
Get the idle timeout.
|
InetSocketAddress |
getLocalAddress() |
HttpOutput.Interceptor |
getNextInterceptor() |
InetSocketAddress |
getRemoteAddress() |
Request |
getRequest() |
RequestLog |
getRequestLog() |
int |
getRequests() |
Response |
getResponse() |
Scheduler |
getScheduler() |
Server |
getServer() |
HttpChannelState |
getState() |
boolean |
handle() |
protected void |
handleException(Throwable x)
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 |
onBadMessage(int status,
String reason) |
void |
onCompleted() |
boolean |
onContent(HttpInput.Content content) |
boolean |
onEarlyEOF() |
void |
onRequest(MetaData.Request request) |
boolean |
onRequestComplete() |
void |
recycle() |
void |
run() |
protected boolean |
sendResponse(MetaData.Response info,
ByteBuffer content,
boolean complete) |
protected boolean |
sendResponse(MetaData.Response info,
ByteBuffer content,
boolean complete,
Callback callback) |
void |
setIdleTimeout(long timeoutMs)
Set the idle timeout.
|
void |
setRequestLog(RequestLog requestLog) |
String |
toString() |
boolean |
useDirectBuffers() |
void |
write(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 int 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.Interceptor
public Server getServer()
public Request getRequest()
public Response getResponse()
public EndPoint getEndPoint()
public InetSocketAddress getLocalAddress()
public InetSocketAddress getRemoteAddress()
public void continue100(int available) throws IOException
available
- estimate of the number of bytes that are availableIOException
- if the InputStream cannot be createdpublic void recycle()
public void asyncReadFillInterested()
public boolean handle()
protected void handleException(Throwable x)
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.
x
- the Throwable that caused the problempublic boolean isExpecting100Continue()
public boolean isExpecting102Processing()
public void onRequest(MetaData.Request request)
public boolean onContent(HttpInput.Content content)
public boolean onRequestComplete()
public void onCompleted()
public boolean onEarlyEOF()
public void onBadMessage(int status, String reason)
protected boolean sendResponse(MetaData.Response info, ByteBuffer content, boolean complete, Callback callback)
protected boolean sendResponse(MetaData.Response info, ByteBuffer content, boolean complete) throws IOException
IOException
protected void commit(MetaData.Response info)
public boolean isCommitted()
public void write(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.Interceptor
content
- the content buffer to writecomplete
- whether the content is complete for the responsecallback
- Callback when complete or failedpublic HttpOutput.Interceptor getNextInterceptor()
getNextInterceptor
in interface HttpOutput.Interceptor
protected void execute(Runnable task)
public Scheduler getScheduler()
public boolean useDirectBuffers()
public void abort(Throwable failure)
The standard implementation calls HttpTransport.abort(Throwable)
.
failure
- the failure that caused the abort.Copyright © 1995-2016 Webtide. All Rights Reserved.