public class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandler, HttpParser.ComplianceHandler
HttpChannel.Listener
Modifier and Type | Field and Description |
---|---|
private java.util.List<java.lang.String> |
_complianceViolations |
private HttpField |
_connection |
private boolean |
_delayedForContent |
private boolean |
_expect100Continue |
private boolean |
_expect102Processing |
private HttpFields |
_fields |
private HttpConnection |
_httpConnection |
private MetaData.Request |
_metadata |
private HttpFields |
_trailers |
private boolean |
_unknownExpectation |
private HttpField |
_upgrade |
private static Logger |
LOG |
private static HttpField |
PREAMBLE_UPGRADE_H2C |
Constructor and Description |
---|
HttpChannelOverHttp(HttpConnection httpConnection,
Connector connector,
HttpConfiguration config,
EndPoint endPoint,
HttpTransport transport) |
Modifier and Type | Method and Description |
---|---|
void |
abort(java.lang.Throwable failure)
If a write or similar operation to this channel fails,
then this method should be called.
|
void |
badMessage(BadMessageException failure)
Called to signal that a bad HTTP message has been received.
|
boolean |
content(java.nio.ByteBuffer content) |
boolean |
contentComplete() |
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
|
int |
getHeaderCacheSize() |
protected void |
handleException(java.lang.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 |
isExpecting100Continue() |
boolean |
isExpecting102Processing() |
boolean |
messageComplete() |
protected HttpInput |
newHttpInput(HttpChannelState state) |
void |
onAsyncWaitForContent() |
void |
onBlockWaitForContent() |
void |
onBlockWaitForContentFailure(java.lang.Throwable failure) |
void |
onComplianceViolation(HttpCompliance compliance,
HttpComplianceSection violation,
java.lang.String reason) |
(package private) boolean |
onIdleTimeout(java.lang.Throwable timeout) |
void |
parsedHeader(HttpField field)
This is the method called by parser when a HTTP Header name and value is found
|
void |
parsedTrailer(HttpField field)
This is the method called by parser when a HTTP Trailer name and value is found
|
void |
recycle() |
boolean |
startRequest(java.lang.String method,
java.lang.String uri,
HttpVersion version)
This is the method called by parser when the HTTP request line is parsed
|
private boolean |
upgrade()
Attempts to perform a HTTP/1.1 upgrade.
|
addRequestLog, commit, execute, getByteBufferPool, getBytesWritten, getCommittedMetaData, getConnector, getEndPoint, getHttpConfiguration, getHttpTransport, getIdleTimeout, getLocalAddress, getNextInterceptor, getRemoteAddress, getRequest, getRequestLog, getRequests, getResponse, getScheduler, getServer, getState, handle, isCommitted, isOptimizedForDirectBuffers, newHttpOutput, onBadMessage, onCompleted, onContent, onContentComplete, onEarlyEOF, onRequest, onRequestComplete, onTrailers, resetBuffer, run, sendError, sendResponse, sendResponse, setIdleTimeout, setRequestLog, toString, useDirectBuffers, write
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
onComplianceViolation
badMessage
private static final Logger LOG
private static final HttpField PREAMBLE_UPGRADE_H2C
private final HttpFields _fields
private final MetaData.Request _metadata
private final HttpConnection _httpConnection
private HttpField _connection
private HttpField _upgrade
private boolean _delayedForContent
private boolean _unknownExpectation
private boolean _expect100Continue
private boolean _expect102Processing
private java.util.List<java.lang.String> _complianceViolations
private HttpFields _trailers
public HttpChannelOverHttp(HttpConnection httpConnection, Connector connector, HttpConfiguration config, EndPoint endPoint, HttpTransport transport)
protected HttpInput newHttpInput(HttpChannelState state)
newHttpInput
in class HttpChannel
public void recycle()
recycle
in class HttpChannel
public boolean isExpecting100Continue()
isExpecting100Continue
in class HttpChannel
public boolean isExpecting102Processing()
isExpecting102Processing
in class HttpChannel
public boolean startRequest(java.lang.String method, java.lang.String uri, HttpVersion version)
HttpParser.RequestHandler
startRequest
in interface HttpParser.RequestHandler
method
- The methoduri
- The raw bytes of the URI. These are copied into a ByteBuffer that will not be changed until this parser is reset and reused.version
- the http version in usepublic void parsedHeader(HttpField field)
HttpParser.HttpHandler
parsedHeader
in interface HttpParser.HttpHandler
field
- The field parsedpublic void parsedTrailer(HttpField field)
HttpParser.HttpHandler
parsedTrailer
in interface HttpParser.HttpHandler
field
- The field parsedpublic void continue100(int available) throws java.io.IOException
continue100
in class HttpChannel
available
- estimate of the number of bytes that are availablejava.io.IOException
- if the InputStream cannot be createdpublic void earlyEOF()
HttpParser.HttpHandler
earlyEOF
in interface HttpParser.HttpHandler
public boolean content(java.nio.ByteBuffer content)
content
in interface HttpParser.HttpHandler
public void onAsyncWaitForContent()
onAsyncWaitForContent
in class HttpChannel
public void onBlockWaitForContent()
onBlockWaitForContent
in class HttpChannel
public void onBlockWaitForContentFailure(java.lang.Throwable failure)
onBlockWaitForContentFailure
in class HttpChannel
public void badMessage(BadMessageException failure)
HttpParser.HttpHandler
badMessage
in interface HttpParser.HttpHandler
failure
- the failure with the bad message informationpublic boolean headerComplete()
headerComplete
in interface HttpParser.HttpHandler
boolean onIdleTimeout(java.lang.Throwable timeout)
private boolean upgrade() throws BadMessageException
Attempts to perform a HTTP/1.1 upgrade.
The upgrade looks up a ConnectionFactory.Upgrading
from the connector
matching the protocol specified in the Upgrade
header.
The upgrade may succeed, be ignored (which can allow a later handler to implement)
or fail with a BadMessageException
.
BadMessageException
- if the upgrade failedprotected void handleException(java.lang.Throwable x)
HttpChannel
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.
handleException
in class HttpChannel
x
- the Throwable that caused the problempublic void abort(java.lang.Throwable failure)
HttpChannel
The standard implementation calls HttpTransport.abort(Throwable)
.
abort
in class HttpChannel
failure
- the failure that caused the abort.public boolean contentComplete()
contentComplete
in interface HttpParser.HttpHandler
public boolean messageComplete()
messageComplete
in interface HttpParser.HttpHandler
public int getHeaderCacheSize()
getHeaderCacheSize
in interface HttpParser.HttpHandler
public void onComplianceViolation(HttpCompliance compliance, HttpComplianceSection violation, java.lang.String reason)
onComplianceViolation
in interface HttpParser.ComplianceHandler