Class Http2ServerConnection
java.lang.Object
io.undertow.util.AbstractAttachable
io.undertow.server.ServerConnection
io.undertow.server.protocol.http2.Http2ServerConnection
- All Implemented Interfaces:
Attachable
,Closeable
,AutoCloseable
,Channel
,InterruptibleChannel
,org.xnio.channels.BoundChannel
,org.xnio.channels.CloseableChannel
,org.xnio.channels.Configurable
,org.xnio.channels.ConnectedChannel
A server connection. There is one connection per request
TODO: how are we going to deal with attachments?
- Author:
- Stuart Douglas
-
Nested Class Summary
Nested classes/interfaces inherited from class io.undertow.server.ServerConnection
ServerConnection.CloseListener
-
Field Summary
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
Constructor Summary
ConstructorsConstructorDescriptionHttp2ServerConnection
(Http2Channel channel, Http2DataStreamSinkChannel sinkChannel, org.xnio.OptionMap undertowOptions, int bufferSize, HttpHandler rootHandler) Channel that is used when the request is already half closedHttp2ServerConnection
(Http2Channel channel, Http2StreamSourceChannel requestChannel, org.xnio.OptionMap undertowOptions, int bufferSize, HttpHandler rootHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a close listener, than will be invoked with the connection is closed<T> void
addToAttachmentList
(AttachmentKey<AttachmentList<T>> key, T value) Add a value to a list-typed attachment key.void
close()
protected void
exchangeComplete
(HttpServerExchange exchange) Invoked when the exchange is complete.<T> T
getAttachment
(AttachmentKey<T> key) Get an attachment value.<T> List<T>
getAttachmentList
(AttachmentKey<? extends List<T>> key) Gets a list attachment value.org.xnio.Pool<ByteBuffer>
int
org.xnio.ChannelListener.Setter<? extends org.xnio.channels.ConnectedChannel>
org.xnio.XnioIoThread
<A extends SocketAddress>
AgetLocalAddress
(Class<A> type) <T> T
getOption
(org.xnio.Option<T> option) Returns the actual address of the remote connection.<A extends SocketAddress>
AgetPeerAddress
(Class<A> type) Returns the actual address of the remote connection.protected org.xnio.conduits.ConduitStreamSinkChannel
protected org.xnio.conduits.StreamSinkConduit
getSinkConduit
(HttpServerExchange exchange, org.xnio.conduits.StreamSinkConduit conduit) Gets the sink conduit that should be used for this request.protected org.xnio.conduits.ConduitStreamSourceChannel
Gets the SSLSession of the underlying connection, or null if SSL is not in use.Gets SSL information about the connection.Returns a string representation describing the protocol used to transmit messages on this connection.org.xnio.OptionMap
org.xnio.XnioWorker
protected boolean
boolean
boolean
isOpen()
boolean
boolean
protected boolean
protected void
maxEntitySizeUpdated
(HttpServerExchange exchange) Callback that is invoked if the max entity size is updated.boolean
pushResource
(String path, HttpString method, HeaderMap requestHeaders) Attempts to push a resource if this connection supports server push.boolean
pushResource
(String path, HttpString method, HeaderMap requestHeaders, HttpHandler handler) Attempts to push a resource if this connection supports server push.<T> T
putAttachment
(AttachmentKey<T> key, T value) Set an attachment value.<T> T
removeAttachment
(AttachmentKey<T> key) Remove an attachment, returning its previous value.sendOutOfBandResponse
(HttpServerExchange exchange) Sends an out of band response, such as a HTTP 100-continue response.protected void
setConnectListener
(HttpUpgradeListener connectListener) <T> T
setOption
(org.xnio.Option<T> option, T value) void
setSslSessionInfo
(SSLSessionInfo sessionInfo) Sets the current SSL information.protected void
setUpgradeListener
(HttpUpgradeListener upgradeListener) boolean
supportsOption
(org.xnio.Option<?> option) void
terminateRequestChannel
(HttpServerExchange exchange) Invoked when the exchange is complete, and there is still data in the request channel.protected org.xnio.StreamConnection
Upgrade the connection, if allowedMethods inherited from class io.undertow.util.AbstractAttachable
createAttachmentMap
-
Constructor Details
-
Http2ServerConnection
public Http2ServerConnection(Http2Channel channel, Http2StreamSourceChannel requestChannel, org.xnio.OptionMap undertowOptions, int bufferSize, HttpHandler rootHandler) -
Http2ServerConnection
public Http2ServerConnection(Http2Channel channel, Http2DataStreamSinkChannel sinkChannel, org.xnio.OptionMap undertowOptions, int bufferSize, HttpHandler rootHandler) Channel that is used when the request is already half closed- Parameters:
channel
-undertowOptions
-bufferSize
-rootHandler
-
-
-
Method Details
-
getBufferPool
- Specified by:
getBufferPool
in classServerConnection
- Returns:
- The connections buffer pool
-
getSslSession
Description copied from class:ServerConnection
Gets the SSLSession of the underlying connection, or null if SSL is not in use. Note that for client cert authServerConnection.getSslSessionInfo()
should be used instead, as it takes into account other information potentially provided by load balancers that terminate SSL- Overrides:
getSslSession
in classServerConnection
- Returns:
- The SSLSession of the connection
-
getByteBufferPool
- Specified by:
getByteBufferPool
in classServerConnection
- Returns:
- The connections buffer pool
-
getWorker
public org.xnio.XnioWorker getWorker()- Specified by:
getWorker
in interfaceorg.xnio.channels.CloseableChannel
- Specified by:
getWorker
in classServerConnection
- Returns:
- The connections worker
-
getIoThread
public org.xnio.XnioIoThread getIoThread()- Specified by:
getIoThread
in interfaceorg.xnio.channels.CloseableChannel
- Specified by:
getIoThread
in classServerConnection
- Returns:
- The IO thread associated with the connection
-
sendOutOfBandResponse
Description copied from class:ServerConnection
Sends an out of band response, such as a HTTP 100-continue response. WARNING: do not attempt to write to the current exchange until the out of band exchange has been fully written. Doing so may have unexpected results. TODO: this needs more thought.- Specified by:
sendOutOfBandResponse
in classServerConnection
- Parameters:
exchange
- The current exchange- Returns:
- The out of band exchange.
-
isContinueResponseSupported
public boolean isContinueResponseSupported()- Specified by:
isContinueResponseSupported
in classServerConnection
- Returns:
true
if this connection supports sending a 100-continue response
-
terminateRequestChannel
Description copied from class:ServerConnection
Invoked when the exchange is complete, and there is still data in the request channel. Some implementations (such as SPDY and HTTP2) have more efficient ways to drain the request than simply reading all data (e.g. RST_STREAM). After this method is invoked the stream will be drained normally.- Specified by:
terminateRequestChannel
in classServerConnection
- Parameters:
exchange
- The current exchange.
-
isOpen
public boolean isOpen()- Specified by:
isOpen
in interfaceChannel
- Specified by:
isOpen
in classServerConnection
- Returns:
- true if the connection is open
-
supportsOption
public boolean supportsOption(org.xnio.Option<?> option) - Specified by:
supportsOption
in interfaceorg.xnio.channels.Configurable
- Specified by:
supportsOption
in classServerConnection
-
getOption
- Specified by:
getOption
in interfaceorg.xnio.channels.Configurable
- Specified by:
getOption
in classServerConnection
- Throws:
IOException
-
setOption
public <T> T setOption(org.xnio.Option<T> option, T value) throws IllegalArgumentException, IOException - Specified by:
setOption
in interfaceorg.xnio.channels.Configurable
- Specified by:
setOption
in classServerConnection
- Throws:
IllegalArgumentException
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.xnio.channels.CloseableChannel
- Specified by:
close
in interfaceInterruptibleChannel
- Specified by:
close
in classServerConnection
- Throws:
IOException
-
getPeerAddress
Description copied from class:ServerConnection
Returns the actual address of the remote connection. This will not take things like X-Forwarded-for into account.- Specified by:
getPeerAddress
in interfaceorg.xnio.channels.ConnectedChannel
- Specified by:
getPeerAddress
in classServerConnection
- Returns:
- The address of the remote peer
-
getPeerAddress
Description copied from class:ServerConnection
Returns the actual address of the remote connection. This will not take things like X-Forwarded-for into account.- Specified by:
getPeerAddress
in interfaceorg.xnio.channels.ConnectedChannel
- Specified by:
getPeerAddress
in classServerConnection
- Type Parameters:
A
- The address type- Parameters:
type
- The type of address to return- Returns:
- The remote endpoint address
-
getCloseSetter
public org.xnio.ChannelListener.Setter<? extends org.xnio.channels.ConnectedChannel> getCloseSetter() -
getLocalAddress
- Specified by:
getLocalAddress
in interfaceorg.xnio.channels.BoundChannel
- Specified by:
getLocalAddress
in classServerConnection
-
getLocalAddress
- Specified by:
getLocalAddress
in interfaceorg.xnio.channels.BoundChannel
- Specified by:
getLocalAddress
in classServerConnection
-
getUndertowOptions
public org.xnio.OptionMap getUndertowOptions()- Specified by:
getUndertowOptions
in classServerConnection
-
getBufferSize
public int getBufferSize()- Specified by:
getBufferSize
in classServerConnection
-
getSslSessionInfo
Description copied from class:ServerConnection
Gets SSL information about the connection. This could represent the actual client connection, or could be providing SSL information that was provided by a front end proxy.- Specified by:
getSslSessionInfo
in classServerConnection
- Returns:
- SSL information about the connection
-
setSslSessionInfo
Description copied from class:ServerConnection
Sets the current SSL information. This can be used by handlers to setup SSL information that was provided by a front end proxy. If this is being set of a per request basis then you must ensure that it is either cleared by an exchange completion listener at the end of the request, or is always set for every request. Otherwise it is possible to SSL information to 'leak' between requests.- Specified by:
setSslSessionInfo
in classServerConnection
- Parameters:
sessionInfo
- The ssl session information
-
addCloseListener
Description copied from class:ServerConnection
Adds a close listener, than will be invoked with the connection is closed- Specified by:
addCloseListener
in classServerConnection
- Parameters:
listener
- The close listener
-
upgradeChannel
protected org.xnio.StreamConnection upgradeChannel()Description copied from class:ServerConnection
Upgrade the connection, if allowed- Specified by:
upgradeChannel
in classServerConnection
- Returns:
- The StreamConnection that should be passed to the upgrade handler
-
getSinkChannel
protected org.xnio.conduits.ConduitStreamSinkChannel getSinkChannel()- Specified by:
getSinkChannel
in classServerConnection
-
getSourceChannel
protected org.xnio.conduits.ConduitStreamSourceChannel getSourceChannel()- Specified by:
getSourceChannel
in classServerConnection
-
getSinkConduit
protected org.xnio.conduits.StreamSinkConduit getSinkConduit(HttpServerExchange exchange, org.xnio.conduits.StreamSinkConduit conduit) Description copied from class:ServerConnection
Gets the sink conduit that should be used for this request. This allows the connection to apply any per-request conduit wrapping that is required, without adding to the response wrappers array. There is no corresponding method for source conduits, as in general conduits can be directly inserted into the connection after the request has been read.- Specified by:
getSinkConduit
in classServerConnection
- Returns:
- The source conduit
-
isUpgradeSupported
protected boolean isUpgradeSupported()- Specified by:
isUpgradeSupported
in classServerConnection
- Returns:
- true if this connection supports HTTP upgrade
-
isConnectSupported
protected boolean isConnectSupported()- Specified by:
isConnectSupported
in classServerConnection
- Returns:
true
if this connection supports the HTTP CONNECT verb
-
exchangeComplete
Description copied from class:ServerConnection
Invoked when the exchange is complete.- Specified by:
exchangeComplete
in classServerConnection
-
setUpgradeListener
- Specified by:
setUpgradeListener
in classServerConnection
-
setConnectListener
- Specified by:
setConnectListener
in classServerConnection
-
maxEntitySizeUpdated
Description copied from class:ServerConnection
Callback that is invoked if the max entity size is updated.- Specified by:
maxEntitySizeUpdated
in classServerConnection
- Parameters:
exchange
- The current exchange
-
addToAttachmentList
Description copied from class:AbstractAttachable
Add a value to a list-typed attachment key. If the key is not mapped, add such a mapping.- Specified by:
addToAttachmentList
in interfaceAttachable
- Overrides:
addToAttachmentList
in classAbstractAttachable
- Type Parameters:
T
- the list value type- Parameters:
key
- the attachment keyvalue
- the value to add
-
removeAttachment
Description copied from class:AbstractAttachable
Remove an attachment, returning its previous value.- Specified by:
removeAttachment
in interfaceAttachable
- Overrides:
removeAttachment
in classAbstractAttachable
- Type Parameters:
T
- the value type- Parameters:
key
- the attachment key- Returns:
- the old value, or
null
if there was none
-
putAttachment
Description copied from class:AbstractAttachable
Set an attachment value. If an attachment for this key was already set, return the original value. If the value being set isnull
, the attachment key is removed.- Specified by:
putAttachment
in interfaceAttachable
- Overrides:
putAttachment
in classAbstractAttachable
- Type Parameters:
T
- the value type- Parameters:
key
- the attachment keyvalue
- the new value- Returns:
- the old value, or
null
if there was none
-
getAttachmentList
Description copied from class:AbstractAttachable
Gets a list attachment value. If not attachment exists for this key an empty list is returned- Specified by:
getAttachmentList
in interfaceAttachable
- Overrides:
getAttachmentList
in classAbstractAttachable
- Type Parameters:
T
- the value type- Parameters:
key
- the attachment key- Returns:
- the value, or an empty list if there is none
-
getAttachment
Description copied from class:AbstractAttachable
Get an attachment value. If no attachment exists for this key,null
is returned.- Specified by:
getAttachment
in interfaceAttachable
- Overrides:
getAttachment
in classAbstractAttachable
- Type Parameters:
T
- the value type- Parameters:
key
- the attachment key- Returns:
- the value, or
null
if there is none
-
isPushSupported
public boolean isPushSupported()- Overrides:
isPushSupported
in classServerConnection
-
isRequestTrailerFieldsSupported
public boolean isRequestTrailerFieldsSupported()- Specified by:
isRequestTrailerFieldsSupported
in classServerConnection
-
pushResource
Description copied from class:ServerConnection
Attempts to push a resource if this connection supports server push. Otherwise the request is ignored. Note that push is always done on a best effort basis, even if this method returns true it is possible that the remote endpoint will reset the stream- Overrides:
pushResource
in classServerConnection
- Parameters:
path
- The path of the resourcemethod
- The request methodrequestHeaders
- The request headers- Returns:
true
if the server attempted the push, false otherwise
-
pushResource
public boolean pushResource(String path, HttpString method, HeaderMap requestHeaders, HttpHandler handler) Description copied from class:ServerConnection
Attempts to push a resource if this connection supports server push. Otherwise the request is ignored. Note that push is always done on a best effort basis, even if this method returns true it is possible that the remote endpoint will reset the stream. TheHttpHandler
passed in will be used to generate the pushed response- Overrides:
pushResource
in classServerConnection
- Parameters:
path
- The path of the resourcemethod
- The request methodrequestHeaders
- The request headers- Returns:
true
if the server attempted the push, false otherwise
-
getTransportProtocol
Description copied from class:ServerConnection
Returns a string representation describing the protocol used to transmit messages on this connection.- Specified by:
getTransportProtocol
in classServerConnection
- Returns:
- the transport protocol
-