Class Http2Protocol
java.lang.Object
org.apache.coyote.http2.Http2Protocol
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAllows the implementation to examine the request and accept or reject it based on what it finds.booleanAre HTTP/2 streams allowed to provide a scheme that is inconsistent with the transport over which the stream was received?byte[]Returns the byte sequence as listed in the IANA registry for this protocol.Returns the name of the protocol as listed in the IANA registry.Returns the timing for 100-continue responses.booleanReturns whether requests and responses are discarded after processing.longReturns the drain timeout in nanoseconds.Returns the global request group info for JMX statistics.Returns the parent HTTP/1.1 protocol handler.getHttpUpgradeName(boolean isSSLEnabled) Returns the name that clients will use to request an upgrade to this protocol.intReturns the initial window size advertised to the client.booleanReturns whether periodic PING frames are disabled.getInternalUpgradeHandler(SocketWrapperBase<?> socketWrapper, Adapter adapter, Request coyoteRequest) Returns an instance of the HTTP upgrade handler for this protocol.longReturns the keep-alive timeout in milliseconds.intReturns the maximum number of concurrently executing streams.longReturns the maximum number of concurrent streams.intReturns the maximum number of headers allowed per request.intReturns the maximum size of request headers in bytes.intReturns the maximum number of trailer headers allowed per request.intReturns the maximum size of trailer headers in bytes.intReturns the payload size threshold for CONTINUATION frame overhead tracking.intReturns the overhead count factor used for overhead frame tracking.intReturns the payload size threshold for DATA frame overhead tracking.intReturns the overhead reset factor used for RST frame tracking.intReturns the payload size threshold for WINDOW_UPDATE frame overhead tracking.getProcessor(SocketWrapperBase<?> socketWrapper, Adapter adapter) Returns a processor instance for processing a connection using this protocol.longReturns the read timeout in milliseconds.longReturns the stream-level read timeout in milliseconds.longReturns the stream-level write timeout in milliseconds.Returns the name of the upgrade protocol (h2 for SSL, h2c for plain).booleanReturns whether sendfile is enabled.longReturns the write timeout in milliseconds.voidsetAllowSchemeMismatch(boolean allowSchemeMismatch) Configure whether HTTP/2 streams atr allowed to provide a scheme that is inconsistent with the transport over which the stream was receivedvoidsetDiscardRequestsAndResponses(boolean discardRequestsAndResponses) Sets whether requests and responses should be discarded after processing.voidsetDrainTimeout(long drainTimeout) Sets the drain timeout in nanoseconds.voidsetHttp11Protocol(AbstractHttp11Protocol<?> http11Protocol) Configure the HTTP/1.1 protocol that this UpgradeProcotol is nested under.voidsetInitialWindowSize(int initialWindowSize) Sets the initial window size advertised to the client.voidsetInitiatePingDisabled(boolean initiatePingDisabled) Disables or enables the periodic PING frames used to keep the connection alive.voidsetKeepAliveTimeout(long keepAliveTimeout) Sets the keep-alive timeout in milliseconds.voidsetMaxConcurrentStreamExecution(int maxConcurrentStreamExecution) Sets the maximum number of concurrently executing streams.voidsetMaxConcurrentStreams(long maxConcurrentStreams) Sets the maximum number of concurrent streams.voidsetMaxHeaderCount(int maxHeaderCount) Sets the maximum number of headers allowed per request.voidsetMaxTrailerCount(int maxTrailerCount) Sets the maximum number of trailer headers allowed per request.voidsetOverheadContinuationThreshold(int overheadContinuationThreshold) Sets the payload size threshold for CONTINUATION frame overhead tracking.voidsetOverheadCountFactor(int overheadCountFactor) Sets the overhead count factor used for overhead frame tracking.voidsetOverheadDataThreshold(int overheadDataThreshold) Sets the payload size threshold for DATA frame overhead tracking.voidsetOverheadResetFactor(int overheadResetFactor) Sets the overhead reset factor used for RST frame tracking.voidsetOverheadWindowUpdateThreshold(int overheadWindowUpdateThreshold) Sets the payload size threshold for WINDOW_UPDATE frame overhead tracking.voidsetReadTimeout(long readTimeout) Sets the read timeout in milliseconds.voidsetStreamReadTimeout(long streamReadTimeout) Sets the stream-level read timeout in milliseconds.voidsetStreamWriteTimeout(long streamWriteTimeout) Sets the stream-level write timeout in milliseconds.voidsetUseSendfile(boolean useSendfile) Enables or disables sendfile.voidsetWriteTimeout(long writeTimeout) Sets the write timeout in milliseconds.booleanuseCompression(Request request, Response response) Determines whether compression should be used for the given request/response pair.
-
Constructor Details
-
Http2Protocol
public Http2Protocol()Creates a new instance of the HTTP/2 protocol handler.
-
-
Method Details
-
getHttpUpgradeName
Description copied from interface:UpgradeProtocolReturns the name that clients will use to request an upgrade to this protocol.- Specified by:
getHttpUpgradeNamein interfaceUpgradeProtocol- 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
nullif upgrade via an HTTP/1.1 upgrade request is not supported.
-
getAlpnIdentifier
public byte[] getAlpnIdentifier()Description copied from interface:UpgradeProtocolReturns the byte sequence as listed in the IANA registry for this protocol.- Specified by:
getAlpnIdentifierin interfaceUpgradeProtocol- Returns:
- The byte sequence as listed in the IANA registry for this protocol or
nullif upgrade via ALPN is not supported.
-
getAlpnName
Description copied from interface:UpgradeProtocolReturns the name of the protocol as listed in the IANA registry.- Specified by:
getAlpnNamein interfaceUpgradeProtocol- 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. IfUpgradeProtocol.getAlpnIdentifier()returns some other byte sequence, then this method returns the empty string. If upgrade via ALPN is not supported thennullis returned.
-
getProcessor
Description copied from interface:UpgradeProtocolReturns a processor instance for processing a connection using this protocol.- Specified by:
getProcessorin interfaceUpgradeProtocol- Parameters:
socketWrapper- The socketWrapper for the connection that requires a processoradapter- 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:UpgradeProtocolReturns an instance of the HTTP upgrade handler for this protocol.- Specified by:
getInternalUpgradeHandlerin interfaceUpgradeProtocol- Parameters:
socketWrapper- The socketadapter- The Adapter to use to configure the new upgrade handlercoyoteRequest- A copy (may be incomplete) of the request that triggered the upgrade- Returns:
- An instance of the HTTP upgrade handler for this protocol
-
accept
Description copied from interface:UpgradeProtocolAllows the implementation to examine the request and accept or reject it based on what it finds.- Specified by:
acceptin interfaceUpgradeProtocol- Parameters:
request- The request that included an upgrade header for this protocol- Returns:
trueif the request is accepted, otherwisefalse
-
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:
trueif a mismatched scheme is permitted, otherwisefalse
-
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-trueif a mismatched scheme is permitted, otherwisefalse
-
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:
trueif sendfile is enabled
-
setUseSendfile
public void setUseSendfile(boolean useSendfile) Enables or disables sendfile.- Parameters:
useSendfile-trueto 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-trueto disable periodic PING frames
-
getInitiatePingDisabled
public boolean getInitiatePingDisabled()Returns whether periodic PING frames are disabled.- Returns:
trueif periodic PING frames are disabled
-
useCompression
-
getContinueResponseTimingInternal
Returns the timing for 100-continue responses.- Returns:
- the continue response timing
-
getHttp11Protocol
Returns the parent HTTP/1.1 protocol handler.- Returns:
- the HTTP/1.1 protocol handler
-
setHttp11Protocol
Description copied from interface:UpgradeProtocolConfigure 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:
setHttp11Protocolin interfaceUpgradeProtocol- Parameters:
http11Protocol- The HTTP/1.1 protocol implementation that will initially handle any connections passed to this UpgradeProtocol via the HTTP upgrade mechanism
-
getUpgradeProtocolName
Returns the name of the upgrade protocol (h2 for SSL, h2c for plain).- Returns:
- the upgrade protocol name
-
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:
trueif requests and responses are discarded
-
setDiscardRequestsAndResponses
public void setDiscardRequestsAndResponses(boolean discardRequestsAndResponses) Sets whether requests and responses should be discarded after processing.- Parameters:
discardRequestsAndResponses-trueto 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
-