public class HttpChannel<T> extends Object implements HttpParser.RequestHandler<T>, Runnable, HttpParser.ProxyHandler
| Constructor and Description |
|---|
HttpChannel(Connector connector,
HttpConfiguration configuration,
EndPoint endPoint,
HttpTransport transport,
HttpInput<T> input) |
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
If a write or similar to this channel fails this method should be called.
|
void |
badMessage(int status,
String reason) |
boolean |
content(T item) |
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.
|
void |
earlyEOF() |
protected void |
execute(Runnable task) |
ByteBufferPool |
getByteBufferPool() |
Connector |
getConnector() |
static HttpChannel<?> |
getCurrentHttpChannel()
Get the current channel that this thread is dispatched to.
|
EndPoint |
getEndPoint() |
int |
getHeaderCacheSize() |
HttpConfiguration |
getHttpConfiguration() |
HttpTransport |
getHttpTransport() |
HttpVersion |
getHttpVersion() |
long |
getIdleTimeout()
Get the idle timeout.
|
InetSocketAddress |
getLocalAddress() |
InetSocketAddress |
getRemoteAddress() |
Request |
getRequest() |
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 |
headerComplete() |
boolean |
isCommitted() |
boolean |
isExpecting100Continue() |
boolean |
isExpecting102Processing() |
boolean |
messageComplete() |
boolean |
parsedHeader(HttpField field) |
boolean |
parsedHostHeader(String host,
int port) |
void |
proxied(String protocol,
String sAddr,
String dAddr,
int sPort,
int dPort) |
void |
reset() |
void |
run() |
protected boolean |
sendResponse(HttpGenerator.ResponseInfo info,
ByteBuffer content,
boolean complete) |
protected boolean |
sendResponse(HttpGenerator.ResponseInfo info,
ByteBuffer content,
boolean complete,
Callback callback) |
protected static HttpChannel<?> |
setCurrentHttpChannel(HttpChannel<?> channel) |
void |
setIdleTimeout(long timeoutMs)
Set the idle timeout.
|
boolean |
startRequest(HttpMethod httpMethod,
String method,
ByteBuffer uri,
HttpVersion version) |
String |
toString() |
boolean |
useDirectBuffers() |
protected 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, HttpInput<T> input)
public static HttpChannel<?> getCurrentHttpChannel()
for a more general way to access the HttpChannelprotected static HttpChannel<?> setCurrentHttpChannel(HttpChannel<?> channel)
public HttpChannelState getState()
public HttpVersion getHttpVersion()
public int getRequests()
public Connector getConnector()
public HttpTransport getHttpTransport()
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 {@link EndPoint#setIdleTimeout(long), but may be overridden by channels that have timeouts different from their connections.
public ByteBufferPool getByteBufferPool()
public HttpConfiguration getHttpConfiguration()
public Server getServer()
public Request getRequest()
public Response getResponse()
public EndPoint getEndPoint()
public InetSocketAddress getLocalAddress()
public InetSocketAddress getRemoteAddress()
public int getHeaderCacheSize()
getHeaderCacheSize in interface HttpParser.HttpHandler<T>public void continue100(int available)
throws IOException
IOException - if the InputStream cannot be createdpublic void reset()
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 proxied(String protocol, String sAddr, String dAddr, int sPort, int dPort)
proxied in interface HttpParser.ProxyHandlerpublic boolean startRequest(HttpMethod httpMethod, String method, ByteBuffer uri, HttpVersion version)
startRequest in interface HttpParser.RequestHandler<T>public boolean parsedHeader(HttpField field)
parsedHeader in interface HttpParser.HttpHandler<T>public boolean parsedHostHeader(String host, int port)
parsedHostHeader in interface HttpParser.RequestHandler<T>public boolean headerComplete()
headerComplete in interface HttpParser.HttpHandler<T>public boolean content(T item)
content in interface HttpParser.HttpHandler<T>public boolean messageComplete()
messageComplete in interface HttpParser.HttpHandler<T>public void earlyEOF()
earlyEOF in interface HttpParser.HttpHandler<T>public void badMessage(int status,
String reason)
badMessage in interface HttpParser.HttpHandler<T>protected boolean sendResponse(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean complete, Callback callback)
protected boolean sendResponse(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean complete) throws IOException
IOExceptionpublic boolean isCommitted()
protected void write(ByteBuffer content, boolean complete, Callback callback)
Non-Blocking write, committing the response if needed.
content - the content buffer to writecomplete - whether the content is complete for the responsecallback - Callback when complete or failedprotected void execute(Runnable task)
public Scheduler getScheduler()
public boolean useDirectBuffers()
public void abort()
HttpTransport.abort()Copyright © 1995-2014 Webtide. All Rights Reserved.