- java.lang.Object
-
- org.eclipse.jetty.server.HttpChannel
-
- org.eclipse.jetty.server.HttpChannelOverHttp
-
- All Implemented Interfaces:
java.lang.Runnable,org.eclipse.jetty.http.ComplianceViolation.Listener,org.eclipse.jetty.http.HttpParser.HttpHandler,org.eclipse.jetty.http.HttpParser.RequestHandler,HttpOutput.Interceptor
public class HttpChannelOverHttp extends HttpChannel implements org.eclipse.jetty.http.HttpParser.RequestHandler, org.eclipse.jetty.http.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, org.eclipse.jetty.io.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(org.eclipse.jetty.http.BadMessageException failure)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 buffer)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()protected booleaneof()Mark the channel's input as EOF.booleanfailAllContent(java.lang.Throwable failure)Fail all content that is currently stored within the channel.booleanfailed(java.lang.Throwable x)Fail the channel's input.org.eclipse.jetty.io.EndPointgetTunnellingEndPoint()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()booleanneedContent()Notify the channel that content is needed.voidonComplianceViolation(org.eclipse.jetty.http.ComplianceViolation.Mode mode, org.eclipse.jetty.http.ComplianceViolation violation, java.lang.String details)voidparsedHeader(org.eclipse.jetty.http.HttpField field)voidparsedTrailer(org.eclipse.jetty.http.HttpField field)HttpInput.ContentproduceContent()Produce aHttpInput.Contentobject with data currently stored within the channel.voidrecycle()voidservletUpgrade()voidstartRequest(java.lang.String method, java.lang.String uri, org.eclipse.jetty.http.HttpVersion version)-
Methods inherited from class org.eclipse.jetty.server.HttpChannel
addListener, addRequestLog, commit, ensureConsumeAllOrNotPersistent, execute, formatAddrOrHost, getByteBufferPool, getBytesWritten, getCommittedMetaData, getConnection, getConnector, getEndPoint, getHttpConfiguration, getHttpTransport, getIdleTimeout, getLocalAddress, getLocalName, getLocalPort, getNextInterceptor, getRemoteAddress, getRequest, getRequestLog, getRequests, getResponse, getScheduler, getServer, getServerAuthority, getState, getTransientListeners, handle, isCommitted, isPersistent, isRequestCompleted, isResponseCompleted, isSendError, newHttpOutput, onBadMessage, onCompleted, onContent, onContentComplete, 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, org.eclipse.jetty.io.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.
-
needContent
public boolean needContent()
Description copied from class:HttpChannelNotify the channel that content is needed. If some content is immediately available, true is returned andHttpChannel.produceContent()has to be called and will return a non-null object. If no content is immediately available, an attempt to produce content must be made; if new content has been produced, true is returned; otherwiseHttpInput.onContentProducible()is called once some content arrives andHttpChannel.produceContent()can be called without returningnull. If a failure happens, thenHttpInput.onContentProducible()will be called and an error content will return the error on the next call toHttpChannel.produceContent().- Specified by:
needContentin classHttpChannel- Returns:
- true if content is immediately available.
-
produceContent
public HttpInput.Content produceContent()
Description copied from class:HttpChannelProduce aHttpInput.Contentobject with data currently stored within the channel. The produced content can be special (meaning callingHttpInput.Content.isSpecial()returns true) if the channel reached a special state, like EOF or an error. Once a special content has been returned, all subsequent calls to this method will always return a special content of the same kind andHttpChannel.needContent()will always return true. The returned content is "raw", i.e.: not decoded.- Specified by:
produceContentin classHttpChannel- Returns:
- a
HttpInput.Contentobject if one is immediately available without blocking, null otherwise.
-
failAllContent
public boolean failAllContent(java.lang.Throwable failure)
Description copied from class:HttpChannelFail all content that is currently stored within the channel.- Specified by:
failAllContentin classHttpChannel- Parameters:
failure- the failure to fail the content with.- Returns:
- true if EOF was reached while failing all content, false otherwise.
-
badMessage
public void badMessage(org.eclipse.jetty.http.BadMessageException failure)
- Specified by:
badMessagein interfaceorg.eclipse.jetty.http.HttpParser.HttpHandler
-
content
public boolean content(java.nio.ByteBuffer buffer)
- Specified by:
contentin interfaceorg.eclipse.jetty.http.HttpParser.HttpHandler
-
contentComplete
public boolean contentComplete()
- Specified by:
contentCompletein interfaceorg.eclipse.jetty.http.HttpParser.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()
- Specified by:
earlyEOFin interfaceorg.eclipse.jetty.http.HttpParser.HttpHandler
-
eof
protected boolean eof()
Description copied from class:HttpChannelMark the channel's input as EOF.- Specified by:
eofin classHttpChannel- Returns:
- true if the channel needs to be rescheduled.
-
failed
public boolean failed(java.lang.Throwable x)
Description copied from class:HttpChannelFail the channel's input.- Specified by:
failedin classHttpChannel- Parameters:
x- the failure.- Returns:
- true if the channel needs to be rescheduled.
-
getTunnellingEndPoint
public org.eclipse.jetty.io.EndPoint getTunnellingEndPoint()
- Overrides:
getTunnellingEndPointin classHttpChannel
-
headerComplete
public boolean headerComplete()
- Specified by:
headerCompletein interfaceorg.eclipse.jetty.http.HttpParser.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 interfaceorg.eclipse.jetty.http.HttpParser.HttpHandler
-
onComplianceViolation
public void onComplianceViolation(org.eclipse.jetty.http.ComplianceViolation.Mode mode, org.eclipse.jetty.http.ComplianceViolation violation, java.lang.String details)- Specified by:
onComplianceViolationin interfaceorg.eclipse.jetty.http.ComplianceViolation.Listener
-
parsedHeader
public void parsedHeader(org.eclipse.jetty.http.HttpField field)
- Specified by:
parsedHeaderin interfaceorg.eclipse.jetty.http.HttpParser.HttpHandler
-
parsedTrailer
public void parsedTrailer(org.eclipse.jetty.http.HttpField field)
- Specified by:
parsedTrailerin interfaceorg.eclipse.jetty.http.HttpParser.HttpHandler
-
recycle
public void recycle()
- Overrides:
recyclein classHttpChannel
-
servletUpgrade
public void servletUpgrade()
-
startRequest
public void startRequest(java.lang.String method, java.lang.String uri, org.eclipse.jetty.http.HttpVersion version)- Specified by:
startRequestin interfaceorg.eclipse.jetty.http.HttpParser.RequestHandler
-
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
-
-