public class HttpChannel<T> extends Object implements HttpParser.RequestHandler<T>, Runnable
Constructor and Description |
---|
HttpChannel(Connector connector,
HttpChannelConfig configuration,
EndPoint endPoint,
HttpTransport transport,
HttpInput<T> input) |
Modifier and Type | Method and Description |
---|---|
void |
badMessage(int status,
String reason) |
protected boolean |
commitResponse(HttpGenerator.ResponseInfo info,
ByteBuffer content,
boolean complete) |
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.
|
boolean |
earlyEOF() |
protected void |
execute(Runnable task) |
ByteBufferPool |
getByteBufferPool() |
Connector |
getConnector() |
static HttpChannel<?> |
getCurrentHttpChannel() |
EndPoint |
getEndPoint() |
HttpChannelConfig |
getHttpChannelConfig() |
HttpVersion |
getHttpVersion() |
InetSocketAddress |
getLocalAddress() |
InetSocketAddress |
getRemoteAddress() |
Request |
getRequest() |
int |
getRequests() |
Response |
getResponse() |
Scheduler |
getScheduler() |
Server |
getServer() |
HttpChannelState |
getState() |
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() |
protected boolean |
isCommitted() |
boolean |
isExpecting100Continue() |
boolean |
isExpecting102Processing() |
boolean |
messageComplete(long contentLength) |
boolean |
parsedHeader(HttpHeader header,
String name,
String value)
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 |
reset() |
void |
run() |
protected static void |
setCurrentHttpChannel(HttpChannel<?> channel) |
boolean |
startRequest(HttpMethod httpMethod,
String method,
String uri,
HttpVersion version)
This is the method called by parser when the HTTP request line is parsed
|
String |
toString() |
protected void |
write(ByteBuffer content,
boolean complete)
Requests to write (in a blocking way) the given response content buffer,
committing the response if needed.
|
public HttpChannel(Connector connector, HttpChannelConfig configuration, EndPoint endPoint, HttpTransport transport, HttpInput<T> input)
public static HttpChannel<?> getCurrentHttpChannel()
protected static void setCurrentHttpChannel(HttpChannel<?> channel)
public HttpChannelState getState()
public HttpVersion getHttpVersion()
public int getRequests()
public Connector getConnector()
public ByteBufferPool getByteBufferPool()
public HttpChannelConfig getHttpChannelConfig()
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
IOException
- if the InputStream cannot be createdpublic void reset()
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 boolean startRequest(HttpMethod httpMethod, String method, String uri, HttpVersion version)
HttpParser.RequestHandler
startRequest
in interface HttpParser.RequestHandler<T>
public boolean parsedHeader(HttpHeader header, String name, String value)
HttpParser.HttpHandler
parsedHeader
in interface HttpParser.HttpHandler<T>
header
- The HttpHeader value if there is a matchname
- The String value of the header namevalue
- The String value of the headerpublic boolean parsedHostHeader(String host, int port)
HttpParser.RequestHandler
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(long contentLength)
messageComplete
in interface HttpParser.HttpHandler<T>
public boolean earlyEOF()
earlyEOF
in interface HttpParser.HttpHandler<T>
public void badMessage(int status, String reason)
badMessage
in interface HttpParser.HttpHandler<T>
protected boolean commitResponse(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean complete) throws IOException
IOException
protected boolean isCommitted()
protected void write(ByteBuffer content, boolean complete) throws IOException
Requests to write (in a blocking way) the given response content buffer, committing the response if needed.
content
- the content buffer to writecomplete
- whether the content is complete for the responseIOException
- if the write failsprotected void execute(Runnable task)
public Scheduler getScheduler()
Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.