Class Http2Protocol

  • All Implemented Interfaces:
    UpgradeProtocol

    public class Http2Protocol
    extends java.lang.Object
    implements UpgradeProtocol
    HTTP/2 protocol handler. Implements the UpgradeProtocol interface to allow HTTP/2 to be used as an upgrade from HTTP/1.1 or via ALPN.
    • Constructor Detail

      • Http2Protocol

        public Http2Protocol()
        Creates a new instance of the HTTP/2 protocol handler.
    • Method Detail

      • getHttpUpgradeName

        public java.lang.String getHttpUpgradeName​(boolean isSSLEnabled)
        Description copied from interface: UpgradeProtocol
        Returns the name that clients will use to request an upgrade to this protocol.
        Specified by:
        getHttpUpgradeName in interface UpgradeProtocol
        Parameters:
        isSSLEnabled - Is this for a connector that is configured to support TLS. Some protocols (e.g. HTTP/2) only support HTTP upgrade over non-secure connections.
        Returns:
        The name that clients will use to request an upgrade to this protocol via an HTTP/1.1 upgrade request or null if upgrade via an HTTP/1.1 upgrade request is not supported.
      • getAlpnIdentifier

        public byte[] getAlpnIdentifier()
        Description copied from interface: UpgradeProtocol
        Returns the byte sequence as listed in the IANA registry for this protocol.
        Specified by:
        getAlpnIdentifier in interface UpgradeProtocol
        Returns:
        The byte sequence as listed in the IANA registry for this protocol or null if upgrade via ALPN is not supported.
      • getAlpnName

        public java.lang.String getAlpnName()
        Description copied from interface: UpgradeProtocol
        Returns the name of the protocol as listed in the IANA registry.
        Specified by:
        getAlpnName in interface UpgradeProtocol
        Returns:
        The name of the protocol as listed in the IANA registry if and only if UpgradeProtocol.getAlpnIdentifier() returns the UTF-8 encoding of this name. If UpgradeProtocol.getAlpnIdentifier() returns some other byte sequence, then this method returns the empty string. If upgrade via ALPN is not supported then null is returned.
      • getProcessor

        public Processor getProcessor​(SocketWrapperBase<?> socketWrapper,
                                      Adapter adapter)
        Description copied from interface: UpgradeProtocol
        Returns a processor instance for processing a connection using this protocol.
        Specified by:
        getProcessor in interface UpgradeProtocol
        Parameters:
        socketWrapper - The socketWrapper for the connection that requires a processor
        adapter - The Adapter instance that provides access to the standard Engine/Host/Context/Wrapper processing chain
        Returns:
        A processor instance for processing a connection using this protocol.
      • getInternalUpgradeHandler

        public InternalHttpUpgradeHandler getInternalUpgradeHandler​(SocketWrapperBase<?> socketWrapper,
                                                                    Adapter adapter,
                                                                    Request coyoteRequest)
        Description copied from interface: UpgradeProtocol
        Returns an instance of the HTTP upgrade handler for this protocol.
        Specified by:
        getInternalUpgradeHandler in interface UpgradeProtocol
        Parameters:
        socketWrapper - The socket
        adapter - The Adapter to use to configure the new upgrade handler
        coyoteRequest - A copy (may be incomplete) of the request that triggered the upgrade
        Returns:
        An instance of the HTTP upgrade handler for this protocol
      • accept

        public boolean accept​(Request request)
        Description copied from interface: UpgradeProtocol
        Allows the implementation to examine the request and accept or reject it based on what it finds.
        Specified by:
        accept in interface UpgradeProtocol
        Parameters:
        request - The request that included an upgrade header for this protocol
        Returns:
        true if the request is accepted, otherwise false
      • getAllowSchemeMismatch

        public boolean getAllowSchemeMismatch()
        Are HTTP/2 streams allowed to provide a scheme that is inconsistent with the transport over which the stream was received?
        Returns:
        true if a mismatched scheme is permitted, otherwise false
      • setAllowSchemeMismatch

        public void setAllowSchemeMismatch​(boolean allowSchemeMismatch)
        Configure whether HTTP/2 streams atr allowed to provide a scheme that is inconsistent with the transport over which the stream was received
        Parameters:
        allowSchemeMismatch - true if a mismatched scheme is permitted, otherwise false
      • getReadTimeout

        public long getReadTimeout()
        Returns the read timeout in milliseconds.
        Returns:
        the read timeout
      • setReadTimeout

        public void setReadTimeout​(long readTimeout)
        Sets the read timeout in milliseconds.
        Parameters:
        readTimeout - the read timeout
      • getWriteTimeout

        public long getWriteTimeout()
        Returns the write timeout in milliseconds.
        Returns:
        the write timeout
      • setWriteTimeout

        public void setWriteTimeout​(long writeTimeout)
        Sets the write timeout in milliseconds.
        Parameters:
        writeTimeout - the write timeout
      • getKeepAliveTimeout

        public long getKeepAliveTimeout()
        Returns the keep-alive timeout in milliseconds.
        Returns:
        the keep-alive timeout
      • setKeepAliveTimeout

        public void setKeepAliveTimeout​(long keepAliveTimeout)
        Sets the keep-alive timeout in milliseconds.
        Parameters:
        keepAliveTimeout - the keep-alive timeout
      • getStreamReadTimeout

        public long getStreamReadTimeout()
        Returns the stream-level read timeout in milliseconds.
        Returns:
        the stream read timeout
      • setStreamReadTimeout

        public void setStreamReadTimeout​(long streamReadTimeout)
        Sets the stream-level read timeout in milliseconds.
        Parameters:
        streamReadTimeout - the stream read timeout
      • getStreamWriteTimeout

        public long getStreamWriteTimeout()
        Returns the stream-level write timeout in milliseconds.
        Returns:
        the stream write timeout
      • setStreamWriteTimeout

        public void setStreamWriteTimeout​(long streamWriteTimeout)
        Sets the stream-level write timeout in milliseconds.
        Parameters:
        streamWriteTimeout - the stream write timeout
      • getMaxConcurrentStreams

        public long getMaxConcurrentStreams()
        Returns the maximum number of concurrent streams.
        Returns:
        the maximum concurrent streams
      • setMaxConcurrentStreams

        public void setMaxConcurrentStreams​(long maxConcurrentStreams)
        Sets the maximum number of concurrent streams.
        Parameters:
        maxConcurrentStreams - the maximum concurrent streams
      • getMaxConcurrentStreamExecution

        public int getMaxConcurrentStreamExecution()
        Returns the maximum number of concurrently executing streams.
        Returns:
        the maximum concurrent stream execution count
      • setMaxConcurrentStreamExecution

        public void setMaxConcurrentStreamExecution​(int maxConcurrentStreamExecution)
        Sets the maximum number of concurrently executing streams.
        Parameters:
        maxConcurrentStreamExecution - the maximum concurrent stream execution count
      • getInitialWindowSize

        public int getInitialWindowSize()
        Returns the initial window size advertised to the client.
        Returns:
        the initial window size
      • setInitialWindowSize

        public void setInitialWindowSize​(int initialWindowSize)
        Sets the initial window size advertised to the client.
        Parameters:
        initialWindowSize - the initial window size
      • getUseSendfile

        public boolean getUseSendfile()
        Returns whether sendfile is enabled.
        Returns:
        true if sendfile is enabled
      • setUseSendfile

        public void setUseSendfile​(boolean useSendfile)
        Enables or disables sendfile.
        Parameters:
        useSendfile - true to enable sendfile
      • setMaxHeaderCount

        public void setMaxHeaderCount​(int maxHeaderCount)
        Sets the maximum number of headers allowed per request.
        Parameters:
        maxHeaderCount - the maximum header count
      • getMaxHeaderCount

        public int getMaxHeaderCount()
        Returns the maximum number of headers allowed per request.
        Returns:
        the maximum header count
      • getMaxHeaderSize

        public int getMaxHeaderSize()
        Returns the maximum size of request headers in bytes.
        Returns:
        the maximum header size
      • setMaxTrailerCount

        public void setMaxTrailerCount​(int maxTrailerCount)
        Sets the maximum number of trailer headers allowed per request.
        Parameters:
        maxTrailerCount - the maximum trailer count
      • getMaxTrailerCount

        public int getMaxTrailerCount()
        Returns the maximum number of trailer headers allowed per request.
        Returns:
        the maximum trailer count
      • getMaxTrailerSize

        public int getMaxTrailerSize()
        Returns the maximum size of trailer headers in bytes.
        Returns:
        the maximum trailer size
      • getOverheadCountFactor

        public int getOverheadCountFactor()
        Returns the overhead count factor used for overhead frame tracking.
        Returns:
        the overhead count factor
      • setOverheadCountFactor

        public void setOverheadCountFactor​(int overheadCountFactor)
        Sets the overhead count factor used for overhead frame tracking.
        Parameters:
        overheadCountFactor - the overhead count factor
      • getOverheadResetFactor

        public int getOverheadResetFactor()
        Returns the overhead reset factor used for RST frame tracking.
        Returns:
        the overhead reset factor
      • setOverheadResetFactor

        public void setOverheadResetFactor​(int overheadResetFactor)
        Sets the overhead reset factor used for RST frame tracking.
        Parameters:
        overheadResetFactor - the overhead reset factor
      • getOverheadContinuationThreshold

        public int getOverheadContinuationThreshold()
        Returns the payload size threshold for CONTINUATION frame overhead tracking.
        Returns:
        the continuation threshold
      • setOverheadContinuationThreshold

        public void setOverheadContinuationThreshold​(int overheadContinuationThreshold)
        Sets the payload size threshold for CONTINUATION frame overhead tracking.
        Parameters:
        overheadContinuationThreshold - the continuation threshold
      • getOverheadDataThreshold

        public int getOverheadDataThreshold()
        Returns the payload size threshold for DATA frame overhead tracking.
        Returns:
        the data threshold
      • setOverheadDataThreshold

        public void setOverheadDataThreshold​(int overheadDataThreshold)
        Sets the payload size threshold for DATA frame overhead tracking.
        Parameters:
        overheadDataThreshold - the data threshold
      • getOverheadWindowUpdateThreshold

        public int getOverheadWindowUpdateThreshold()
        Returns the payload size threshold for WINDOW_UPDATE frame overhead tracking.
        Returns:
        the window update threshold
      • setOverheadWindowUpdateThreshold

        public void setOverheadWindowUpdateThreshold​(int overheadWindowUpdateThreshold)
        Sets the payload size threshold for WINDOW_UPDATE frame overhead tracking.
        Parameters:
        overheadWindowUpdateThreshold - the window update threshold
      • setInitiatePingDisabled

        public void setInitiatePingDisabled​(boolean initiatePingDisabled)
        Disables or enables the periodic PING frames used to keep the connection alive.
        Parameters:
        initiatePingDisabled - true to disable periodic PING frames
      • getInitiatePingDisabled

        public boolean getInitiatePingDisabled()
        Returns whether periodic PING frames are disabled.
        Returns:
        true if periodic PING frames are disabled
      • useCompression

        public boolean useCompression​(Request request,
                                      Response response)
        Determines whether compression should be used for the given request/response pair.
        Parameters:
        request - The request
        response - The response
        Returns:
        true if compression should be used
      • getContinueResponseTimingInternal

        public ContinueResponseTiming getContinueResponseTimingInternal()
        Returns the timing for 100-continue responses.
        Returns:
        the continue response timing
      • getHttp11Protocol

        public AbstractHttp11Protocol<?> getHttp11Protocol()
        Returns the parent HTTP/1.1 protocol handler.
        Returns:
        the HTTP/1.1 protocol handler
      • setHttp11Protocol

        public void setHttp11Protocol​(AbstractHttp11Protocol<?> http11Protocol)
        Description copied from interface: UpgradeProtocol
        Configure the HTTP/1.1 protocol that this UpgradeProcotol is nested under. Connections passed to this UpgradeProtocol via HTTP upgrade will have been initially handled by this HTTP/1.1 protocol implementation.

        The default implementation is a NO-OP.

        Specified by:
        setHttp11Protocol in interface UpgradeProtocol
        Parameters:
        http11Protocol - The HTTP/1.1 protocol implementation that will initially handle any connections passed to this UpgradeProtocol via the HTTP upgrade mechanism
      • getUpgradeProtocolName

        public java.lang.String getUpgradeProtocolName()
        Returns the name of the upgrade protocol (h2 for SSL, h2c for plain).
        Returns:
        the upgrade protocol name
      • getGlobal

        public RequestGroupInfo getGlobal()
        Returns the global request group info for JMX statistics.
        Returns:
        the global request group info
      • getDiscardRequestsAndResponses

        public boolean getDiscardRequestsAndResponses()
        Returns whether requests and responses are discarded after processing.
        Returns:
        true if requests and responses are discarded
      • setDiscardRequestsAndResponses

        public void setDiscardRequestsAndResponses​(boolean discardRequestsAndResponses)
        Sets whether requests and responses should be discarded after processing.
        Parameters:
        discardRequestsAndResponses - true to discard requests and responses
      • getDrainTimeout

        public long getDrainTimeout()
        Returns the drain timeout in nanoseconds.
        Returns:
        the drain timeout
      • setDrainTimeout

        public void setDrainTimeout​(long drainTimeout)
        Sets the drain timeout in nanoseconds.
        Parameters:
        drainTimeout - the drain timeout