- java.lang.Object
-
- org.eclipse.jetty.server.HttpChannel
-
- org.eclipse.jetty.server.HttpChannelOverHttp
-
- All Implemented Interfaces:
java.lang.Runnable,ComplianceViolation.Listener,HttpParser.HttpHandler,HttpParser.RequestHandler,HttpOutput.Interceptor
public class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandler, ComplianceViolation.Listener
An HttpChannel customized to be transported over the HTTP/1 protocol
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.server.HttpChannel
HttpChannel.Listener, HttpChannel.TransientListeners
-
-
Field Summary
-
Fields inherited from class org.eclipse.jetty.server.HttpChannel
NOOP_LISTENER
-
-
Constructor Summary
Constructors Constructor Description HttpChannelOverHttp(HttpConnection httpConnection, Connector connector, HttpConfiguration config, EndPoint endPoint, HttpTransport transport)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort(java.lang.Throwable failure)If a write or similar operation to this channel fails, then this method should be called.voidbadMessage(BadMessageException failure)Called to signal that a bad HTTP message has been received.protected booleancheckAndPrepareUpgrade()Checks whether the processing of the request resulted in an upgrade, and if so performs upgrade preparation steps before the upgrade response is sent back to the client.booleancontent(java.nio.ByteBuffer content)booleancontentComplete()voidcontinue100(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.voidearlyEOF()Called to signal that an EOF was received unexpectedly during the parsing of an HTTP messageEndPointgetTunnellingEndPoint()protected voidhandleException(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.booleanheaderComplete()booleanisExpecting100Continue()booleanisExpecting102Processing()booleanisTunnellingSupported()booleanisUseOutputDirectByteBuffers()booleanmessageComplete()protected HttpInputnewHttpInput(HttpChannelState state)voidonAsyncWaitForContent()voidonBlockWaitForContent()voidonBlockWaitForContentFailure(java.lang.Throwable failure)voidonComplianceViolation(ComplianceViolation.Mode mode, ComplianceViolation violation, java.lang.String details)voidparsedHeader(HttpField field)This is the method called by parser when an HTTP Header name and value is foundvoidparsedTrailer(HttpField field)This is the method called by parser when an HTTP Trailer name and value is foundvoidrecycle()voidstartRequest(java.lang.String method, java.lang.String uri, HttpVersion version)This is the method called by parser when the HTTP request line is parsed-
Methods inherited from class org.eclipse.jetty.server.HttpChannel
addListener, addRequestLog, commit, execute, getByteBufferPool, getBytesWritten, getCommittedMetaData, getConnection, getConnector, getEndPoint, getHttpConfiguration, getHttpTransport, getIdleTimeout, getLocalAddress, getNextInterceptor, getRemoteAddress, getRequest, getRequestLog, getRequests, getResponse, getScheduler, getServer, getState, getTransientListeners, handle, isCommitted, isPersistent, isRequestCompleted, isResponseCompleted, isSendError, newHttpOutput, onBadMessage, onCompleted, onContent, onContentComplete, onEarlyEOF, onRequest, onRequestComplete, onTrailers, removeListener, resetBuffer, run, sendErrorOrAbort, sendResponse, sendResponse, sendResponseAndComplete, setIdleTimeout, setRequestLog, toString, unwrap, write
-
-
-
-
Constructor Detail
-
HttpChannelOverHttp
public HttpChannelOverHttp(HttpConnection httpConnection, Connector connector, HttpConfiguration config, EndPoint endPoint, HttpTransport transport)
-
-
Method Detail
-
abort
public void abort(java.lang.Throwable failure)
Description copied from class:HttpChannelIf a write or similar operation to this channel fails, then this method should be called.The standard implementation calls
HttpTransport.abort(Throwable).- Overrides:
abortin classHttpChannel- Parameters:
failure- the failure that caused the abort.
-
badMessage
public void badMessage(BadMessageException failure)
Description copied from interface:HttpParser.HttpHandlerCalled to signal that a bad HTTP message has been received.- Specified by:
badMessagein interfaceHttpParser.HttpHandler- Parameters:
failure- the failure with the bad message information
-
content
public boolean content(java.nio.ByteBuffer content)
- Specified by:
contentin interfaceHttpParser.HttpHandler
-
contentComplete
public boolean contentComplete()
- Specified by:
contentCompletein interfaceHttpParser.HttpHandler
-
continue100
public void continue100(int available) throws java.io.IOExceptionIf 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.- Overrides:
continue100in classHttpChannel- Parameters:
available- estimate of the number of bytes that are available- Throws:
java.io.IOException- if the InputStream cannot be created
-
earlyEOF
public void earlyEOF()
Description copied from interface:HttpParser.HttpHandlerCalled to signal that an EOF was received unexpectedly during the parsing of an HTTP message- Specified by:
earlyEOFin interfaceHttpParser.HttpHandler
-
getTunnellingEndPoint
public EndPoint getTunnellingEndPoint()
- Overrides:
getTunnellingEndPointin classHttpChannel
-
headerComplete
public boolean headerComplete()
- Specified by:
headerCompletein interfaceHttpParser.HttpHandler
-
isExpecting100Continue
public boolean isExpecting100Continue()
- Overrides:
isExpecting100Continuein classHttpChannel
-
isExpecting102Processing
public boolean isExpecting102Processing()
- Overrides:
isExpecting102Processingin classHttpChannel
-
isTunnellingSupported
public boolean isTunnellingSupported()
- Overrides:
isTunnellingSupportedin classHttpChannel
-
isUseOutputDirectByteBuffers
public boolean isUseOutputDirectByteBuffers()
- Overrides:
isUseOutputDirectByteBuffersin classHttpChannel
-
messageComplete
public boolean messageComplete()
- Specified by:
messageCompletein interfaceHttpParser.HttpHandler
-
onAsyncWaitForContent
public void onAsyncWaitForContent()
- Overrides:
onAsyncWaitForContentin classHttpChannel
-
onBlockWaitForContent
public void onBlockWaitForContent()
- Overrides:
onBlockWaitForContentin classHttpChannel
-
onBlockWaitForContentFailure
public void onBlockWaitForContentFailure(java.lang.Throwable failure)
- Overrides:
onBlockWaitForContentFailurein classHttpChannel
-
onComplianceViolation
public void onComplianceViolation(ComplianceViolation.Mode mode, ComplianceViolation violation, java.lang.String details)
- Specified by:
onComplianceViolationin interfaceComplianceViolation.Listener
-
parsedHeader
public void parsedHeader(HttpField field)
Description copied from interface:HttpParser.HttpHandlerThis is the method called by parser when an HTTP Header name and value is found- Specified by:
parsedHeaderin interfaceHttpParser.HttpHandler- Parameters:
field- The field parsed
-
parsedTrailer
public void parsedTrailer(HttpField field)
Description copied from interface:HttpParser.HttpHandlerThis is the method called by parser when an HTTP Trailer name and value is found- Specified by:
parsedTrailerin interfaceHttpParser.HttpHandler- Parameters:
field- The field parsed
-
recycle
public void recycle()
- Overrides:
recyclein classHttpChannel
-
startRequest
public void startRequest(java.lang.String method, java.lang.String uri, HttpVersion version)Description copied from interface:HttpParser.RequestHandlerThis is the method called by parser when the HTTP request line is parsed- Specified by:
startRequestin interfaceHttpParser.RequestHandler- Parameters:
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 use
-
checkAndPrepareUpgrade
protected boolean checkAndPrepareUpgrade()
Description copied from class:HttpChannelChecks whether the processing of the request resulted in an upgrade, and if so performs upgrade preparation steps before the upgrade response is sent back to the client.
This avoids a race where the server is unprepared if the client sends data immediately after having received the upgrade response.
- Overrides:
checkAndPrepareUpgradein classHttpChannel- Returns:
- true if the channel is not complete and more processing is required, typically because sendError has been called.
-
handleException
protected void handleException(java.lang.Throwable x)
Description copied from class:HttpChannelSends 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
ErrorHandlermechanisms and the response OutputStream.- Overrides:
handleExceptionin classHttpChannel- Parameters:
x- the Throwable that caused the problem
-
newHttpInput
protected HttpInput newHttpInput(HttpChannelState state)
- Overrides:
newHttpInputin classHttpChannel
-
-