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 TypeMethodDescriptionvoidAdds a close listener, than will be invoked with the connection is closed<T> voidaddToAttachmentList(AttachmentKey<AttachmentList<T>> key, T value) Add a value to a list-typed attachment key.voidclose()protected voidexchangeComplete(HttpServerExchange exchange) Invoked when the exchange is complete.<T> TgetAttachment(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>intorg.xnio.ChannelListener.Setter<? extends org.xnio.channels.ConnectedChannel>org.xnio.XnioIoThread<A extends SocketAddress>
AgetLocalAddress(Class<A> type) <T> TgetOption(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.ConduitStreamSinkChannelprotected org.xnio.conduits.StreamSinkConduitgetSinkConduit(HttpServerExchange exchange, org.xnio.conduits.StreamSinkConduit conduit) Gets the sink conduit that should be used for this request.protected org.xnio.conduits.ConduitStreamSourceChannelGets 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.OptionMaporg.xnio.XnioWorkerprotected booleanbooleanbooleanisOpen()booleanbooleanprotected booleanprotected voidmaxEntitySizeUpdated(HttpServerExchange exchange) Callback that is invoked if the max entity size is updated.booleanpushResource(String path, HttpString method, HeaderMap requestHeaders) Attempts to push a resource if this connection supports server push.booleanpushResource(String path, HttpString method, HeaderMap requestHeaders, HttpHandler handler) Attempts to push a resource if this connection supports server push.<T> TputAttachment(AttachmentKey<T> key, T value) Set an attachment value.<T> TremoveAttachment(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 voidsetConnectListener(HttpUpgradeListener connectListener) <T> TsetOption(org.xnio.Option<T> option, T value) voidsetSslSessionInfo(SSLSessionInfo sessionInfo) Sets the current SSL information.protected voidsetUpgradeListener(HttpUpgradeListener upgradeListener) booleansupportsOption(org.xnio.Option<?> option) voidterminateRequestChannel(HttpServerExchange exchange) Invoked when the exchange is complete, and there is still data in the request channel.protected org.xnio.StreamConnectionUpgrade 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:
getBufferPoolin classServerConnection- Returns:
- The connections buffer pool
-
getSslSession
Description copied from class:ServerConnectionGets 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:
getSslSessionin classServerConnection- Returns:
- The SSLSession of the connection
-
getByteBufferPool
- Specified by:
getByteBufferPoolin classServerConnection- Returns:
- The connections buffer pool
-
getWorker
public org.xnio.XnioWorker getWorker()- Specified by:
getWorkerin interfaceorg.xnio.channels.CloseableChannel- Specified by:
getWorkerin classServerConnection- Returns:
- The connections worker
-
getIoThread
public org.xnio.XnioIoThread getIoThread()- Specified by:
getIoThreadin interfaceorg.xnio.channels.CloseableChannel- Specified by:
getIoThreadin classServerConnection- Returns:
- The IO thread associated with the connection
-
sendOutOfBandResponse
Description copied from class:ServerConnectionSends 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:
sendOutOfBandResponsein classServerConnection- Parameters:
exchange- The current exchange- Returns:
- The out of band exchange.
-
isContinueResponseSupported
public boolean isContinueResponseSupported()- Specified by:
isContinueResponseSupportedin classServerConnection- Returns:
trueif this connection supports sending a 100-continue response
-
terminateRequestChannel
Description copied from class:ServerConnectionInvoked 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:
terminateRequestChannelin classServerConnection- Parameters:
exchange- The current exchange.
-
isOpen
public boolean isOpen()- Specified by:
isOpenin interfaceChannel- Specified by:
isOpenin classServerConnection- Returns:
- true if the connection is open
-
supportsOption
public boolean supportsOption(org.xnio.Option<?> option) - Specified by:
supportsOptionin interfaceorg.xnio.channels.Configurable- Specified by:
supportsOptionin classServerConnection
-
getOption
- Specified by:
getOptionin interfaceorg.xnio.channels.Configurable- Specified by:
getOptionin classServerConnection- Throws:
IOException
-
setOption
public <T> T setOption(org.xnio.Option<T> option, T value) throws IllegalArgumentException, IOException - Specified by:
setOptionin interfaceorg.xnio.channels.Configurable- Specified by:
setOptionin classServerConnection- Throws:
IllegalArgumentExceptionIOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceorg.xnio.channels.CloseableChannel- Specified by:
closein interfaceInterruptibleChannel- Specified by:
closein classServerConnection- Throws:
IOException
-
getPeerAddress
Description copied from class:ServerConnectionReturns the actual address of the remote connection. This will not take things like X-Forwarded-for into account.- Specified by:
getPeerAddressin interfaceorg.xnio.channels.ConnectedChannel- Specified by:
getPeerAddressin classServerConnection- Returns:
- The address of the remote peer
-
getPeerAddress
Description copied from class:ServerConnectionReturns the actual address of the remote connection. This will not take things like X-Forwarded-for into account.- Specified by:
getPeerAddressin interfaceorg.xnio.channels.ConnectedChannel- Specified by:
getPeerAddressin 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:
getLocalAddressin interfaceorg.xnio.channels.BoundChannel- Specified by:
getLocalAddressin classServerConnection
-
getLocalAddress
- Specified by:
getLocalAddressin interfaceorg.xnio.channels.BoundChannel- Specified by:
getLocalAddressin classServerConnection
-
getUndertowOptions
public org.xnio.OptionMap getUndertowOptions()- Specified by:
getUndertowOptionsin classServerConnection
-
getBufferSize
public int getBufferSize()- Specified by:
getBufferSizein classServerConnection
-
getSslSessionInfo
Description copied from class:ServerConnectionGets 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:
getSslSessionInfoin classServerConnection- Returns:
- SSL information about the connection
-
setSslSessionInfo
Description copied from class:ServerConnectionSets 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:
setSslSessionInfoin classServerConnection- Parameters:
sessionInfo- The ssl session information
-
addCloseListener
Description copied from class:ServerConnectionAdds a close listener, than will be invoked with the connection is closed- Specified by:
addCloseListenerin classServerConnection- Parameters:
listener- The close listener
-
upgradeChannel
protected org.xnio.StreamConnection upgradeChannel()Description copied from class:ServerConnectionUpgrade the connection, if allowed- Specified by:
upgradeChannelin classServerConnection- Returns:
- The StreamConnection that should be passed to the upgrade handler
-
getSinkChannel
protected org.xnio.conduits.ConduitStreamSinkChannel getSinkChannel()- Specified by:
getSinkChannelin classServerConnection
-
getSourceChannel
protected org.xnio.conduits.ConduitStreamSourceChannel getSourceChannel()- Specified by:
getSourceChannelin classServerConnection
-
getSinkConduit
protected org.xnio.conduits.StreamSinkConduit getSinkConduit(HttpServerExchange exchange, org.xnio.conduits.StreamSinkConduit conduit) Description copied from class:ServerConnectionGets 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:
getSinkConduitin classServerConnection- Returns:
- The source conduit
-
isUpgradeSupported
protected boolean isUpgradeSupported()- Specified by:
isUpgradeSupportedin classServerConnection- Returns:
- true if this connection supports HTTP upgrade
-
isConnectSupported
protected boolean isConnectSupported()- Specified by:
isConnectSupportedin classServerConnection- Returns:
trueif this connection supports the HTTP CONNECT verb
-
exchangeComplete
Description copied from class:ServerConnectionInvoked when the exchange is complete.- Specified by:
exchangeCompletein classServerConnection
-
setUpgradeListener
- Specified by:
setUpgradeListenerin classServerConnection
-
setConnectListener
- Specified by:
setConnectListenerin classServerConnection
-
maxEntitySizeUpdated
Description copied from class:ServerConnectionCallback that is invoked if the max entity size is updated.- Specified by:
maxEntitySizeUpdatedin classServerConnection- Parameters:
exchange- The current exchange
-
addToAttachmentList
Description copied from class:AbstractAttachableAdd a value to a list-typed attachment key. If the key is not mapped, add such a mapping.- Specified by:
addToAttachmentListin interfaceAttachable- Overrides:
addToAttachmentListin classAbstractAttachable- Type Parameters:
T- the list value type- Parameters:
key- the attachment keyvalue- the value to add
-
removeAttachment
Description copied from class:AbstractAttachableRemove an attachment, returning its previous value.- Specified by:
removeAttachmentin interfaceAttachable- Overrides:
removeAttachmentin classAbstractAttachable- Type Parameters:
T- the value type- Parameters:
key- the attachment key- Returns:
- the old value, or
nullif there was none
-
putAttachment
Description copied from class:AbstractAttachableSet 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:
putAttachmentin interfaceAttachable- Overrides:
putAttachmentin classAbstractAttachable- Type Parameters:
T- the value type- Parameters:
key- the attachment keyvalue- the new value- Returns:
- the old value, or
nullif there was none
-
getAttachmentList
Description copied from class:AbstractAttachableGets a list attachment value. If not attachment exists for this key an empty list is returned- Specified by:
getAttachmentListin interfaceAttachable- Overrides:
getAttachmentListin 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:AbstractAttachableGet an attachment value. If no attachment exists for this key,nullis returned.- Specified by:
getAttachmentin interfaceAttachable- Overrides:
getAttachmentin classAbstractAttachable- Type Parameters:
T- the value type- Parameters:
key- the attachment key- Returns:
- the value, or
nullif there is none
-
isPushSupported
public boolean isPushSupported()- Overrides:
isPushSupportedin classServerConnection
-
isRequestTrailerFieldsSupported
public boolean isRequestTrailerFieldsSupported()- Specified by:
isRequestTrailerFieldsSupportedin classServerConnection
-
pushResource
Description copied from class:ServerConnectionAttempts 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:
pushResourcein classServerConnection- Parameters:
path- The path of the resourcemethod- The request methodrequestHeaders- The request headers- Returns:
trueif the server attempted the push, false otherwise
-
pushResource
public boolean pushResource(String path, HttpString method, HeaderMap requestHeaders, HttpHandler handler) Description copied from class:ServerConnectionAttempts 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. TheHttpHandlerpassed in will be used to generate the pushed response- Overrides:
pushResourcein classServerConnection- Parameters:
path- The path of the resourcemethod- The request methodrequestHeaders- The request headers- Returns:
trueif the server attempted the push, false otherwise
-
getTransportProtocol
Description copied from class:ServerConnectionReturns a string representation describing the protocol used to transmit messages on this connection.- Specified by:
getTransportProtocolin classServerConnection- Returns:
- the transport protocol
-