Class HttpConnection
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Runnable
,Connection
,Connection.UpgradeFrom
,Connection.UpgradeTo
,ConnectionMetaData
,Attributes
,Invocable
A Connection
that handles the HTTP protocol.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
protected class
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Attributes
Attributes.Layer, Attributes.Lazy, Attributes.Mapped, Attributes.Synthetic
Nested classes/interfaces inherited from interface org.eclipse.jetty.io.Connection
Connection.Listener, Connection.UpgradeFrom, Connection.UpgradeTo
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.ConnectionMetaData
ConnectionMetaData.Wrapper
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task
-
Field Summary
Fields inherited from interface org.eclipse.jetty.util.Attributes
NULL
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking, NOOP
-
Constructor Summary
ConstructorDescriptionHttpConnection
(HttpConfiguration configuration, Connector connector, EndPoint endPoint) HttpConnection
(HttpConfiguration configuration, Connector connector, EndPoint endPoint, boolean recordComplianceViolations) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Clear all attribute namesvoid
close()
Performs a logical close of this connection.getAttribute
(String name) Get an attributeGet the immutable set of attribute names.long
long
static HttpConnection
Get the current connection that this thread is dispatched to.getId()
long
long
boolean
boolean
Deprecated, for removal: This API element is subject to removal in a future version.No replacement, no longer used withinHttpConnection
, will be removed in Jetty 12.1.0boolean
boolean
boolean
protected HttpChannel
newHttpChannel
(Server server, HttpConfiguration configuration) protected HttpGenerator
protected HttpParser
newHttpParser
(HttpCompliance compliance) protected HttpConnection.HttpStreamOverHTTP1
newHttpStream
(String method, String uri, HttpVersion version) protected HttpConnection.RequestHandler
void
Callback method invoked when the endpoint is ready to be read.protected void
onFillInterestedFailed
(Throwable cause) Callback method invoked when the endpoint failed to be ready to be read.boolean
onIdleExpired
(TimeoutException timeout) Callback method invoked upon an idle timeout event.void
onOpen()
Callback method invoked when this connection is opened.Invoked during anupgrade
to produce a buffer containing bytes that have not been consumed by this connection, and that must be consumed by the upgrade-to connection.void
onUpgradeTo
(ByteBuffer buffer) Invoked during anupgrade
to receive a buffer containing bytes that have not been consumed by the upgrade-from connection, and that must be consumed by this connection.removeAttribute
(String name) Remove an attributevoid
run()
setAttribute
(String name, Object attribute) Set an attributeprotected static HttpConnection
setCurrentConnection
(HttpConnection connection) void
setUseInputDirectByteBuffers
(boolean useInputDirectByteBuffers) void
setUseOutputDirectByteBuffers
(boolean useOutputDirectByteBuffers) Methods inherited from class org.eclipse.jetty.server.AbstractMetaDataConnection
getConnection, getConnector, getHttpConfiguration, getLocalSocketAddress, getRemoteSocketAddress
Methods inherited from class org.eclipse.jetty.io.AbstractConnection
addEventListener, failedCallback, fillInterested, getCreatedTimeStamp, getEndPoint, getExecutor, getInputBufferSize, isFillInterested, onClose, onReadTimeout, removeEventListener, setInputBufferSize, toString, tryFillInterested
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.Attributes
asAttributeMap, equals, hashCode
Methods inherited from interface org.eclipse.jetty.server.ConnectionMetaData
getConnection, getConnector, getHttpConfiguration, getLocalSocketAddress, getRemoteSocketAddress, getServerAuthority, isPushSupported, isSecure
-
Constructor Details
-
HttpConnection
@Deprecated(since="12.0.6", forRemoval=true) public HttpConnection(HttpConfiguration configuration, Connector connector, EndPoint endPoint, boolean recordComplianceViolations) Deprecated, for removal: This API element is subject to removal in a future version.useHttpConnection(HttpConfiguration, Connector, EndPoint)
instead. Will be removed in Jetty 12.1.0 -
HttpConnection
-
-
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
-
getInvocationType
- Specified by:
getInvocationType
in interfaceInvocable
- Overrides:
getInvocationType
in classAbstractConnection
- Returns:
- The InvocationType of this object
-
isRecordHttpComplianceViolations
Deprecated, for removal: This API element is subject to removal in a future version.No replacement, no longer used withinHttpConnection
, will be removed in Jetty 12.1.0 -
newHttpGenerator
-
newHttpParser
-
newHttpChannel
-
newHttpStream
protected HttpConnection.HttpStreamOverHTTP1 newHttpStream(String method, String uri, HttpVersion version) -
newRequestHandler
-
getServer
-
getHttpChannel
-
getParser
-
getGenerator
-
getId
- Specified by:
getId
in interfaceConnectionMetaData
- Returns:
- a unique (within the lifetime of the JVM) identifier string for the network connection to the JVM
-
getHttpVersion
- Specified by:
getHttpVersion
in interfaceConnectionMetaData
-
getProtocol
- Specified by:
getProtocol
in interfaceConnectionMetaData
-
isPersistent
public boolean isPersistent()- Specified by:
isPersistent
in interfaceConnectionMetaData
-
removeAttribute
Description copied from interface:Attributes
Remove an attribute- Specified by:
removeAttribute
in interfaceAttributes
- Parameters:
name
- the attribute to remove- Returns:
- the value of the attribute if removed, else
null
-
setAttribute
Description copied from interface:Attributes
Set an attribute- Specified by:
setAttribute
in interfaceAttributes
- Parameters:
name
- the attribute to setattribute
- the value to set. A null value is equivalent to removing the attribute.- Returns:
- the previous value of the attribute if set, else
null
-
getAttribute
Description copied from interface:Attributes
Get an attribute- Specified by:
getAttribute
in interfaceAttributes
- Parameters:
name
- the attribute to get- Returns:
- the value of the attribute, or
null
if no such attribute exists
-
getAttributeNameSet
Description copied from interface:Attributes
Get the immutable set of attribute names.- Specified by:
getAttributeNameSet
in interfaceAttributes
- Returns:
- Set of attribute names, or an empty set if there are no attributes.
-
clearAttributes
public void clearAttributes()Description copied from interface:Attributes
Clear all attribute names- Specified by:
clearAttributes
in interfaceAttributes
-
getMessagesIn
public long getMessagesIn()- Specified by:
getMessagesIn
in interfaceConnection
- Overrides:
getMessagesIn
in classAbstractConnection
-
getMessagesOut
public long getMessagesOut()- Specified by:
getMessagesOut
in interfaceConnection
- Overrides:
getMessagesOut
in classAbstractConnection
-
isUseInputDirectByteBuffers
public boolean isUseInputDirectByteBuffers() -
setUseInputDirectByteBuffers
public void setUseInputDirectByteBuffers(boolean useInputDirectByteBuffers) -
isUseOutputDirectByteBuffers
public boolean isUseOutputDirectByteBuffers() -
setUseOutputDirectByteBuffers
public void setUseOutputDirectByteBuffers(boolean useOutputDirectByteBuffers) -
onUpgradeFrom
Description copied from interface:Connection.UpgradeFrom
Invoked during an
upgrade
to produce a buffer containing bytes that have not been consumed by this connection, and that must be consumed by the upgrade-to connection.- Specified by:
onUpgradeFrom
in interfaceConnection.UpgradeFrom
- Returns:
- a buffer of unconsumed bytes to pass to the upgrade-to connection. The buffer does not belong to any pool and should be discarded after having consumed its bytes. The returned buffer may be null if there are no unconsumed bytes.
-
onUpgradeTo
Description copied from interface:Connection.UpgradeTo
Invoked during an
upgrade
to receive a buffer containing bytes that have not been consumed by the upgrade-from connection, and that must be consumed by this connection.- Specified by:
onUpgradeTo
in interfaceConnection.UpgradeTo
- Parameters:
buffer
- a non-null buffer of unconsumed bytes received from the upgrade-from connection. The buffer does not belong to any pool and should be discarded after having consumed its bytes.
-
isRequestBufferEmpty
public boolean isRequestBufferEmpty() -
onFillable
public void onFillable()Description copied from class:AbstractConnection
Callback method invoked when the endpoint is ready to be read.
- Specified by:
onFillable
in classAbstractConnection
- See Also:
-
onFillInterestedFailed
Description copied from class:AbstractConnection
Callback method invoked when the endpoint failed to be ready to be read.
- Overrides:
onFillInterestedFailed
in classAbstractConnection
- Parameters:
cause
- the exception that caused the failure
-
onIdleExpired
Description copied from interface:Connection
Callback method invoked upon an idle timeout event.
Implementations of this method may return true to indicate that the idle timeout handling should proceed normally, typically failing the EndPoint and causing it to be closed.
When false is returned, the handling of the idle timeout event is halted immediately and the EndPoint left in the state it was before the idle timeout event.
- Specified by:
onIdleExpired
in interfaceConnection
- Overrides:
onIdleExpired
in classAbstractConnection
- Returns:
- true to let the EndPoint handle the idle timeout, false to tell the EndPoint to halt the handling of the idle timeout.
-
close
public void close()Description copied from interface:Connection
Performs a logical close of this connection.
For simple connections, this may just mean to delegate the close to the associated
EndPoint
but, for example, SSL connections should write the SSL close message before closing the associatedEndPoint
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceConnection
- Overrides:
close
in classAbstractConnection
-
onOpen
public void onOpen()Description copied from interface:Connection
Callback method invoked when this connection is opened.
Creators of the connection implementation are responsible for calling this method.
- Specified by:
onOpen
in interfaceConnection
- Overrides:
onOpen
in classAbstractConnection
-
run
public void run() -
asyncReadFillInterested
public void asyncReadFillInterested() -
getBytesIn
public long getBytesIn()- Specified by:
getBytesIn
in interfaceConnection
- Overrides:
getBytesIn
in classAbstractConnection
-
getBytesOut
public long getBytesOut()- Specified by:
getBytesOut
in interfaceConnection
- Overrides:
getBytesOut
in classAbstractConnection
-
toConnectionString
- Overrides:
toConnectionString
in classAbstractConnection
-
HttpConnection(HttpConfiguration, Connector, EndPoint)
instead.