Package org.eclipse.jetty.server
Class HttpConnection
java.lang.Object
org.eclipse.jetty.io.AbstractConnection
org.eclipse.jetty.server.HttpConnection
- All Implemented Interfaces:
Closeable,AutoCloseable,Runnable,Connection,Connection.UpgradeFrom,Connection.UpgradeTo,WriteFlusher.Listener,HttpTransport
public class HttpConnection
extends AbstractConnection
implements Runnable, HttpTransport, WriteFlusher.Listener, Connection.UpgradeFrom, Connection.UpgradeTo
A Connection that handles the HTTP protocol.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.io.Connection
Connection.Listener, Connection.UpgradeFrom, Connection.UpgradeTo -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHttpConnection(HttpConfiguration config, Connector connector, EndPoint endPoint, HttpCompliance compliance, boolean recordComplianceViolations) -
Method Summary
Modifier and TypeMethodDescriptionvoidAborts this transport.voidvoidvoidprotected booleanFill and parse data looking for contentlonglongstatic HttpConnectionGet the current connection that this thread is dispatched to.Deprecated.longlongbooleanIs the underlying transport optimized for DirectBuffer usagebooleanbooleanbooleanprotected HttpChannelOverHttpprotected HttpGeneratorprotected HttpParsernewHttpParser(HttpCompliance compliance) protected HttpParser.RequestHandlervoidonClose()voidCalled to indicated the end of the current request/response cycle (which may be some time after the last content is sent).voidprotected voidonFillInterestedFailed(Throwable cause) voidonFlushed(long bytes) voidonOpen()protected booleanonReadTimeout(Throwable timeout) voidonUpgradeTo(ByteBuffer buffer) voidpush(MetaData.Request request) voidrun()voidsend(MetaData.Response info, boolean head, ByteBuffer content, boolean lastContent, org.eclipse.jetty.util.Callback callback) Asynchronous call to send a response (or part) over the transportprotected static HttpConnectionsetCurrentConnection(HttpConnection connection) Methods inherited from class org.eclipse.jetty.io.AbstractConnection
addListener, close, failedCallback, fillInterested, getCreatedTimeStamp, getEndPoint, getExecutor, getInputBufferSize, isFillInterested, onIdleExpired, removeListener, setInputBufferSize, toString, tryFillInterested, tryFillInterested
-
Field Details
-
CONNECTION_CLOSE
-
UPGRADE_CONNECTION_ATTRIBUTE
- See Also:
-
-
Constructor Details
-
HttpConnection
public HttpConnection(HttpConfiguration config, Connector connector, EndPoint endPoint, HttpCompliance compliance, boolean recordComplianceViolations)
-
-
Method Details
-
getCurrentConnection
Get the current connection that this thread is dispatched to. Note that a thread may be processing a request asynchronously and thus not be dispatched to the connection.- Returns:
- the current HttpConnection or null
- See Also:
-
setCurrentConnection
-
getHttpCompliance
Deprecated. -
getHttpConfiguration
-
isRecordHttpComplianceViolations
public boolean isRecordHttpComplianceViolations() -
newHttpGenerator
-
newHttpChannel
-
newHttpParser
-
newRequestHandler
-
getServer
-
getConnector
-
getHttpChannel
-
getParser
-
getGenerator
-
isOptimizedForDirectBuffers
public boolean isOptimizedForDirectBuffers()Description copied from interface:HttpTransportIs the underlying transport optimized for DirectBuffer usage- Specified by:
isOptimizedForDirectBuffersin interfaceHttpTransport- Returns:
- True if direct buffers can be used optimally.
-
getMessagesIn
public long getMessagesIn()- Specified by:
getMessagesInin interfaceConnection- Overrides:
getMessagesInin classAbstractConnection
-
getMessagesOut
public long getMessagesOut()- Specified by:
getMessagesOutin interfaceConnection- Overrides:
getMessagesOutin classAbstractConnection
-
onUpgradeFrom
- Specified by:
onUpgradeFromin interfaceConnection.UpgradeFrom
-
onUpgradeTo
- Specified by:
onUpgradeToin interfaceConnection.UpgradeTo
-
onFlushed
- Specified by:
onFlushedin interfaceWriteFlusher.Listener- Throws:
IOException
-
getRequestBuffer
-
isRequestBufferEmpty
public boolean isRequestBufferEmpty() -
onFillable
public void onFillable()- Specified by:
onFillablein classAbstractConnection
-
fillAndParseForContent
protected boolean fillAndParseForContent()Fill and parse data looking for content- Returns:
- true if an
HttpParser.RequestHandlermethod was called and it returned true;
-
onCompleted
public void onCompleted()Description copied from interface:HttpTransportCalled to indicated the end of the current request/response cycle (which may be some time after the last content is sent).- Specified by:
onCompletedin interfaceHttpTransport
-
onReadTimeout
- Overrides:
onReadTimeoutin classAbstractConnection
-
onFillInterestedFailed
- Overrides:
onFillInterestedFailedin classAbstractConnection
-
onOpen
public void onOpen()- Specified by:
onOpenin interfaceConnection- Overrides:
onOpenin classAbstractConnection
-
onClose
public void onClose()- Specified by:
onClosein interfaceConnection- Overrides:
onClosein classAbstractConnection
-
run
public void run() -
send
public void send(MetaData.Response info, boolean head, ByteBuffer content, boolean lastContent, org.eclipse.jetty.util.Callback callback) Description copied from interface:HttpTransportAsynchronous call to send a response (or part) over the transport- Specified by:
sendin interfaceHttpTransport- Parameters:
info- The header info to send, or null if just sending more data. The first call to send for a response must have a non null info.head- True if the response if for a HEAD request (and the data should not be sent).content- A buffer of content to be sent.lastContent- True if the content is the last content for the current response.callback- The Callback instance that success or failure of the send is notified on
-
abort
Description copied from interface:HttpTransportAborts this transport.This method should terminate the transport in a way that can indicate an abnormal response to the client, for example by abruptly close the connection.
This method is called when an error response needs to be sent, but the response is already committed, or when a write failure is detected. If abort is called,
HttpTransport.onCompleted()is not called- Specified by:
abortin interfaceHttpTransport- Parameters:
failure- the failure that caused the abort.
-
isPushSupported
public boolean isPushSupported()- Specified by:
isPushSupportedin interfaceHttpTransport- Returns:
- true if responses can be pushed over this transport
-
push
- Specified by:
pushin interfaceHttpTransport- Parameters:
request- A request to use as the basis for generating a pushed response.
-
asyncReadFillInterested
public void asyncReadFillInterested() -
blockingReadFillInterested
public void blockingReadFillInterested() -
blockingReadFailure
-
getBytesIn
public long getBytesIn()- Specified by:
getBytesInin interfaceConnection- Overrides:
getBytesInin classAbstractConnection
-
getBytesOut
public long getBytesOut()- Specified by:
getBytesOutin interfaceConnection- Overrides:
getBytesOutin classAbstractConnection
-
toConnectionString
- Overrides:
toConnectionStringin classAbstractConnection
-