Class 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

    public class Http2ServerConnection
    extends ServerConnection
    A server connection. There is one connection per request TODO: how are we going to deal with attachments?
    Author:
    Stuart Douglas
    • Constructor Detail

      • 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 Detail

      • getSslSession

        public SSLSession 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 auth ServerConnection.getSslSessionInfo() should be used instead, as it takes into account other information potentially provided by load balancers that terminate SSL
        Overrides:
        getSslSession in class ServerConnection
        Returns:
        The SSLSession of the connection
      • getWorker

        public org.xnio.XnioWorker getWorker()
        Specified by:
        getWorker in interface org.xnio.channels.CloseableChannel
        Specified by:
        getWorker in class ServerConnection
        Returns:
        The connections worker
      • getIoThread

        public org.xnio.XnioIoThread getIoThread()
        Specified by:
        getIoThread in interface org.xnio.channels.CloseableChannel
        Specified by:
        getIoThread in class ServerConnection
        Returns:
        The IO thread associated with the connection
      • sendOutOfBandResponse

        public HttpServerExchange sendOutOfBandResponse​(HttpServerExchange exchange)
        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 class ServerConnection
        Parameters:
        exchange - The current exchange
        Returns:
        The out of band exchange.
      • isContinueResponseSupported

        public boolean isContinueResponseSupported()
        Specified by:
        isContinueResponseSupported in class ServerConnection
        Returns:
        true if this connection supports sending a 100-continue response
      • terminateRequestChannel

        public void terminateRequestChannel​(HttpServerExchange exchange)
        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 class ServerConnection
        Parameters:
        exchange - The current exchange.
      • supportsOption

        public boolean supportsOption​(org.xnio.Option<?> option)
        Specified by:
        supportsOption in interface org.xnio.channels.Configurable
        Specified by:
        supportsOption in class ServerConnection
      • getPeerAddress

        public SocketAddress 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 interface org.xnio.channels.ConnectedChannel
        Specified by:
        getPeerAddress in class ServerConnection
        Returns:
        The address of the remote peer
      • getPeerAddress

        public <A extends SocketAddress> A getPeerAddress​(Class<A> type)
        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 interface org.xnio.channels.ConnectedChannel
        Specified by:
        getPeerAddress in class ServerConnection
        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()
      • getSslSessionInfo

        public SSLSessionInfo 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 class ServerConnection
        Returns:
        SSL information about the connection
      • setSslSessionInfo

        public void setSslSessionInfo​(SSLSessionInfo sessionInfo)
        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 class ServerConnection
        Parameters:
        sessionInfo - The ssl session information
      • upgradeChannel

        protected org.xnio.StreamConnection upgradeChannel()
        Description copied from class: ServerConnection
        Upgrade the connection, if allowed
        Specified by:
        upgradeChannel in class ServerConnection
        Returns:
        The StreamConnection that should be passed to the upgrade handler
      • 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 class ServerConnection
        Returns:
        The source conduit
      • isUpgradeSupported

        protected boolean isUpgradeSupported()
        Specified by:
        isUpgradeSupported in class ServerConnection
        Returns:
        true if this connection supports HTTP upgrade
      • isConnectSupported

        protected boolean isConnectSupported()
        Specified by:
        isConnectSupported in class ServerConnection
        Returns:
        true if this connection supports the HTTP CONNECT verb
      • putAttachment

        public <T> T putAttachment​(AttachmentKey<T> key,
                                   T value)
        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 is null, the attachment key is removed.
        Specified by:
        putAttachment in interface Attachable
        Overrides:
        putAttachment in class AbstractAttachable
        Type Parameters:
        T - the value type
        Parameters:
        key - the attachment key
        value - the new value
        Returns:
        the old value, or null if there was none
      • getAttachment

        public <T> T getAttachment​(AttachmentKey<T> key)
        Description copied from class: AbstractAttachable
        Get an attachment value. If no attachment exists for this key, null is returned.
        Specified by:
        getAttachment in interface Attachable
        Overrides:
        getAttachment in class AbstractAttachable
        Type Parameters:
        T - the value type
        Parameters:
        key - the attachment key
        Returns:
        the value, or null if there is none
      • pushResource

        public boolean pushResource​(String path,
                                    HttpString method,
                                    HeaderMap requestHeaders)
        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 class ServerConnection
        Parameters:
        path - The path of the resource
        method - The request method
        requestHeaders - 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. The HttpHandler passed in will be used to generate the pushed response
        Overrides:
        pushResource in class ServerConnection
        Parameters:
        path - The path of the resource
        method - The request method
        requestHeaders - The request headers
        Returns:
        true if the server attempted the push, false otherwise
      • getTransportProtocol

        public String getTransportProtocol()
        Description copied from class: ServerConnection
        Returns a string representation describing the protocol used to transmit messages on this connection.
        Specified by:
        getTransportProtocol in class ServerConnection
        Returns:
        the transport protocol