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)
Called to signal that a bad HTTP message has been received.
|
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()
Called to signal that an EOF was received unexpectedly
during the parsing of a HTTP message
|
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)
This is the method called by parser when a HTTP Header name and value is found
|
boolean |
parsedHostHeader(String host,
int port)
This is the method called by the parser after it has parsed the host header (and checked it's format).
|
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)
This is the method called by parser when the HTTP request line is parsed
|
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)
HttpParser.RequestHandlerstartRequest in interface HttpParser.RequestHandler<T>httpMethod - The method as enum if of a known typemethod - The method as a stringuri - The raw bytes of the URI. These are copied into a ByteBuffer that will not be changed until this parser is reset and reused.public boolean parsedHeader(HttpField field)
HttpParser.HttpHandlerparsedHeader in interface HttpParser.HttpHandler<T>field - The field parsedpublic boolean parsedHostHeader(String host, int port)
HttpParser.RequestHandlerHttpParser.HttpHandler.parsedHeader(HttpField) methods and before
HttpHandler#headerComplete();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()
HttpParser.HttpHandlerearlyEOF in interface HttpParser.HttpHandler<T>public void badMessage(int status,
String reason)
HttpParser.HttpHandlerbadMessage in interface HttpParser.HttpHandler<T>status - The bad status to sendreason - The textual reason for badnessprotected 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-2015 Webtide. All Rights Reserved.