Class HttpChannelOverHttp
- 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 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.protected boolean
checkAndPrepareUpgrade()
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.boolean
content(java.nio.ByteBuffer buffer)
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 an HTTP messageprotected boolean
eof()
Mark the channel's input as EOF.boolean
failAllContent(java.lang.Throwable failure)
Fail all content that is currently stored within the channel.boolean
failed(java.lang.Throwable x)
Fail the channel's input.EndPoint
getTunnellingEndPoint()
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
isTunnellingSupported()
boolean
isUseOutputDirectByteBuffers()
boolean
messageComplete()
boolean
needContent()
Notify the channel that content is needed.void
onComplianceViolation(ComplianceViolation.Mode mode, ComplianceViolation violation, java.lang.String details)
void
parsedHeader(HttpField field)
This is the method called by parser when an HTTP Header name and value is foundvoid
parsedTrailer(HttpField field)
This is the method called by parser when an HTTP Trailer name and value is foundHttpInput.Content
produceContent()
Produce aHttpInput.Content
object with data currently stored within the channel.void
recycle()
void
servletUpgrade()
void
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-
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, isUseInputDirectByteBuffers, 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, EndPoint endPoint, HttpTransport transport)
-
-
Method Detail
-
abort
public void abort(java.lang.Throwable failure)
Description copied from class:HttpChannel
If a write or similar operation to this channel fails, then this method should be called.The standard implementation calls
HttpTransport.abort(Throwable)
.- Overrides:
abort
in classHttpChannel
- Parameters:
failure
- the failure that caused the abort.
-
needContent
public boolean needContent()
Description copied from class:HttpChannel
Notify 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:
needContent
in classHttpChannel
- Returns:
- true if content is immediately available.
-
produceContent
public HttpInput.Content produceContent()
Description copied from class:HttpChannel
Produce aHttpInput.Content
object 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:
produceContent
in classHttpChannel
- Returns:
- a
HttpInput.Content
object if one is immediately available without blocking, null otherwise.
-
failAllContent
public boolean failAllContent(java.lang.Throwable failure)
Description copied from class:HttpChannel
Fail all content that is currently stored within the channel.- Specified by:
failAllContent
in 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(BadMessageException failure)
Description copied from interface:HttpParser.HttpHandler
Called to signal that a bad HTTP message has been received.- Specified by:
badMessage
in interfaceHttpParser.HttpHandler
- Parameters:
failure
- the failure with the bad message information
-
content
public boolean content(java.nio.ByteBuffer buffer)
- Specified by:
content
in interfaceHttpParser.HttpHandler
-
contentComplete
public boolean contentComplete()
- Specified by:
contentComplete
in interfaceHttpParser.HttpHandler
-
continue100
public void continue100(int available) throws java.io.IOException
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.- Overrides:
continue100
in 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.HttpHandler
Called to signal that an EOF was received unexpectedly during the parsing of an HTTP message- Specified by:
earlyEOF
in interfaceHttpParser.HttpHandler
-
eof
protected boolean eof()
Description copied from class:HttpChannel
Mark the channel's input as EOF.- Specified by:
eof
in classHttpChannel
- Returns:
- true if the channel needs to be rescheduled.
-
failed
public boolean failed(java.lang.Throwable x)
Description copied from class:HttpChannel
Fail the channel's input.- Specified by:
failed
in classHttpChannel
- Parameters:
x
- the failure.- Returns:
- true if the channel needs to be rescheduled.
-
getTunnellingEndPoint
public EndPoint getTunnellingEndPoint()
- Overrides:
getTunnellingEndPoint
in classHttpChannel
-
headerComplete
public boolean headerComplete()
- Specified by:
headerComplete
in interfaceHttpParser.HttpHandler
-
isExpecting100Continue
public boolean isExpecting100Continue()
- Overrides:
isExpecting100Continue
in classHttpChannel
-
isExpecting102Processing
public boolean isExpecting102Processing()
- Overrides:
isExpecting102Processing
in classHttpChannel
-
isTunnellingSupported
public boolean isTunnellingSupported()
- Overrides:
isTunnellingSupported
in classHttpChannel
-
isUseOutputDirectByteBuffers
public boolean isUseOutputDirectByteBuffers()
- Overrides:
isUseOutputDirectByteBuffers
in classHttpChannel
-
messageComplete
public boolean messageComplete()
- Specified by:
messageComplete
in interfaceHttpParser.HttpHandler
-
onComplianceViolation
public void onComplianceViolation(ComplianceViolation.Mode mode, ComplianceViolation violation, java.lang.String details)
- Specified by:
onComplianceViolation
in interfaceComplianceViolation.Listener
-
parsedHeader
public void parsedHeader(HttpField field)
Description copied from interface:HttpParser.HttpHandler
This is the method called by parser when an HTTP Header name and value is found- Specified by:
parsedHeader
in interfaceHttpParser.HttpHandler
- Parameters:
field
- The field parsed
-
parsedTrailer
public void parsedTrailer(HttpField field)
Description copied from interface:HttpParser.HttpHandler
This is the method called by parser when an HTTP Trailer name and value is found- Specified by:
parsedTrailer
in interfaceHttpParser.HttpHandler
- Parameters:
field
- The field parsed
-
recycle
public void recycle()
- Overrides:
recycle
in classHttpChannel
-
servletUpgrade
public void servletUpgrade()
-
startRequest
public void startRequest(java.lang.String method, java.lang.String uri, HttpVersion version)
Description copied from interface:HttpParser.RequestHandler
This is the method called by parser when the HTTP request line is parsed- Specified by:
startRequest
in 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:HttpChannel
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.
This avoids a race where the server is unprepared if the client sends data immediately after having received the upgrade response.
- Overrides:
checkAndPrepareUpgrade
in 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: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.- Overrides:
handleException
in classHttpChannel
- Parameters:
x
- the Throwable that caused the problem
-
-