Http2AsyncUpgradeHandler (Apache Tomcat 9.0.111 API Documentation)
Description: declaration: package: org.apache.coyote.http2, class: Http2AsyncUpgradeHandler

# Class Http2AsyncUpgradeHandler

java.lang.Object
org.apache.coyote.http2.Http2AsyncUpgradeHandler

All Implemented Interfaces:
  `HttpUpgradeHandler, InternalHttpUpgradeHandler`

public class Http2AsyncUpgradeHandler extends Object

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected class`
  `Http2AsyncUpgradeHandler.AsyncPingManager`
  `protected class`
  `Http2AsyncUpgradeHandler.SendfileCompletionHandler`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final AtomicInteger`
  `activeRemoteStreamCount`
  `protected final String`
  `connectionId`
  `protected static final int`
  `FLAG_END_OF_HEADERS`
  `protected static final int`
  `FLAG_END_OF_STREAM`
  `protected static final byte[]`
  `GOAWAY`
  `protected static final org.apache.coyote.http2.HeaderSink`
  `HEADER_SINK`
  `protected final org.apache.coyote.http2.ConnectionSettingsLocal`
  `localSettings`
  Local settings are settings defined by Tomcat and sent to the client that the client must use when communicating with Tomcat.
  `protected static final Log`
  `log`
  `protected static final byte[]`
  `PING`
  `protected static final byte[]`
  `PING_ACK`
  `protected final Http2Protocol`
  `protocol`
  `protected static final byte[]`
  `SETTINGS_ACK`
  `protected static final StringManager`
  `sm`
  `protected SocketWrapperBase<?>`
  `socketWrapper`
  `protected static final UserDataHelper`
  `userDataHelper`
  `protected final Condition`
  `windowAllocationAvailable`
  `protected final Lock`
  `windowAllocationLock`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Http2AsyncUpgradeHandler(Http2Protocol protocol, Adapter adapter, Request coyoteRequest)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected byte[]`
  `createWindowUpdateForSettings()`
  `protected void`
  `decrementActiveRemoteStreamCount(org.apache.coyote.http2.Stream stream)`
  `void`
  `destroy()`
  This method is called after the upgraded connection has been closed.
  `protected org.apache.coyote.http2.Http2UpgradeHandler.HeaderFrameBuffers`
  `doWriteHeaders(org.apache.coyote.http2.Stream stream, int pushedStreamId, MimeHeaders mimeHeaders, boolean endOfStream, int payloadSize)`
  `void`
  `endRequestBodyFrame(int streamId, int dataLength)`
  `default boolean`
  `fill(boolean block, byte[] data)`
  `boolean`
  `fill(boolean block, byte[] data, int offset, int length)`
  `default boolean`
  `fill(boolean block, ByteBuffer data, int len)`
  `protected final String`
  `getConnectionId()`
  `protected org.apache.coyote.http2.Http2UpgradeHandler.HeaderFrameBuffers`
  `getHeaderFrameBuffers(int initialPayloadSize)`
  `HpackDecoder`
  `getHpackDecoder()`
  `protected org.apache.coyote.http2.HpackEncoder`
  `getHpackEncoder()`
  `int`
  `getMaxFrameSize()`
  `protected org.apache.coyote.http2.Http2Parser`
  `getParser(String connectionId)`
  `protected org.apache.coyote.http2.Http2UpgradeHandler.PingManager`
  `getPingManager()`
  `void`
  `goaway(int lastStreamId, long errorCode, String debugData)`
  `protected void`
  `handleAppInitiatedIOException(IOException ioe)`
  `boolean`
  `hasAsyncIO()`
  `void`
  `headersContinue(int payloadSize, boolean endOfHeaders)`
  `void`
  `headersEnd(int streamId, boolean endOfStream)`
  `org.apache.coyote.http2.HpackDecoder.HeaderEmitter`
  `headersStart(int streamId, boolean headersEndStream)`
  `void`
  `increaseOverheadCount(org.apache.coyote.http2.FrameType frameType)`
  `protected void`
  `increaseOverheadCount(org.apache.coyote.http2.FrameType frameType, int increment)`
  Used to increase the overhead for frames that don't use the `overheadCountFactor` (`CONTINUATION`, `DATA`, `WINDOW_UPDATE` and `RESET`).
  `protected void`
  `incrementWindowSize(int increment)`
  `void`
  `incrementWindowSize(int streamId, int increment)`
  `void`
  `init(WebConnection webConnection)`
  This method is called once the request/response pair where `HttpServletRequest.upgrade(Class)` is called has completed processing and is the point where control of the connection passes from the container to the `HttpUpgradeHandler`.
  `void`
  `onSwallowedDataFramePayload(int streamId, int swallowedDataBytesCount)`
  `void`
  `onSwallowedUnknownFrame(int streamId, int frameTypeId, int flags, int size)`
  `void`
  `pause()`
  Pause processing for the connection.
  `void`
  `pingReceive(byte[] payload, boolean ack)`
  `void`
  `priorityUpdate(int prioritizedStreamID, Priority p)`
  `protected void`
  `processConnection(WebConnection webConnection, org.apache.coyote.http2.Stream stream)`
  `protected SendfileState`
  `processSendfile(org.apache.coyote.http2.SendfileData sendfile)`
  Process send file (if supported) for the given stream.
  `protected void`
  `processStreamOnContainerThread(org.apache.coyote.http2.Stream stream)`
  `protected void`
  `processWrites()`
  `void`
  `receivedEndOfStream(int streamId)`
  `void`
  `reprioritise(int streamId, int parentStreamId, boolean exclusive, int weight)`
  Deprecated.
  Unused.
  `void`
  `reset(int streamId, long errorCode)`
  `protected void`
  `sentEndOfStream(org.apache.coyote.http2.Stream stream)`
  `protected void`
  `setConnectionTimeoutForStreamCount(int streamCount)`
  `void`
  `setSocketWrapper(SocketWrapperBase<?> wrapper)`
  Associate with the specified socket.
  `void`
  `setSslSupport(SSLSupport sslSupport)`
  Associate with the specified SSL support.
  `void`
  `setting(org.apache.coyote.http2.Setting setting, long value)`
  `void`
  `settingsEnd(boolean ack)`
  `ByteBuffer`
  `startRequestBodyFrame(int streamId, int dataLength, boolean endOfStream)`
  `void`
  `timeoutAsync(long now)`
  Check for a possible timeout.
  `AbstractEndpoint.Handler.SocketState`
  `upgradeDispatch(SocketEvent status)`
  Process the specified event.
  `protected void`
  `writeGoAwayFrame(int maxStreamId, long errorCode, byte[] debugMsg)`
  `protected void`
  `writeSettings()`
  Write the initial settings frame and any necessary supporting frames.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface InternalHttpUpgradeHandler

  `getUpgradeInfo`

- ## Field Details

  - ### log

    protected static final Log log

  - ### sm

    protected static final StringManager sm

  - ### FLAG_END_OF_STREAM

    protected static final int FLAG_END_OF_STREAM
    See Also:
      - Constant Field Values

  - ### FLAG_END_OF_HEADERS

    protected static final int FLAG_END_OF_HEADERS
    See Also:
      - Constant Field Values

  - ### PING

    protected static final byte[] PING

  - ### PING_ACK

    protected static final byte[] PING_ACK

  - ### SETTINGS_ACK

    protected static final byte[] SETTINGS_ACK

  - ### GOAWAY

    protected static final byte[] GOAWAY

  - ### HEADER_SINK

    protected static final org.apache.coyote.http2.HeaderSink HEADER_SINK

  - ### userDataHelper

    protected static final UserDataHelper userDataHelper

  - ### connectionId

    protected final String connectionId

  - ### protocol

    protected final Http2Protocol protocol

  - ### socketWrapper

    protected volatile SocketWrapperBase<?> socketWrapper

  - ### localSettings

    protected final org.apache.coyote.http2.ConnectionSettingsLocal localSettings
    Local settings are settings defined by Tomcat and sent to the client that the client must use when communicating with Tomcat.

  - ### activeRemoteStreamCount

    protected final AtomicInteger activeRemoteStreamCount

  - ### windowAllocationLock

    protected final Lock windowAllocationLock

  - ### windowAllocationAvailable

    protected final Condition windowAllocationAvailable

- ## Constructor Details

  - ### Http2AsyncUpgradeHandler

    public Http2AsyncUpgradeHandler(Http2Protocol protocol, Adapter adapter, Request coyoteRequest)

- ## Method Details

  - ### getParser

    protected org.apache.coyote.http2.Http2Parser getParser(String connectionId)

  - ### getPingManager

    protected org.apache.coyote.http2.Http2UpgradeHandler.PingManager getPingManager()

  - ### hasAsyncIO

    public boolean hasAsyncIO()
    Returns:
      `true` if able to process asynchronous IO, default is `false`

  - ### processConnection

    protected void processConnection(WebConnection webConnection, org.apache.coyote.http2.Stream stream)

  - ### writeSettings

    protected void writeSettings()
    Write the initial settings frame and any necessary supporting frames. If the initial settings increase the initial window size, it will also be necessary to send a WINDOW_UPDATE frame to increase the size of the flow control window for the connection (stream 0).

  - ### writeGoAwayFrame

    protected void writeGoAwayFrame(int maxStreamId, long errorCode, byte[] debugMsg) throws IOException
    Throws:
      `IOException`

  - ### getHeaderFrameBuffers

    protected org.apache.coyote.http2.Http2UpgradeHandler.HeaderFrameBuffers getHeaderFrameBuffers(int initialPayloadSize)

  - ### settingsEnd

    public void settingsEnd(boolean ack) throws IOException
    Throws:
      `IOException`

  - ### processSendfile

    protected SendfileState processSendfile(org.apache.coyote.http2.SendfileData sendfile)
    Process send file (if supported) for the given stream. The appropriate request attributes should be set before calling this method.
    Parameters:
      `sendfile` - The stream and associated data to process
    Returns:
      The result of the send file processing

  - ### init

    public void init(WebConnection webConnection)
    Description copied from interface: `javax.servlet.http.HttpUpgradeHandler`
    This method is called once the request/response pair where `HttpServletRequest.upgrade(Class)` is called has completed processing and is the point where control of the connection passes from the container to the `HttpUpgradeHandler`.
    Specified by:
      `init` in interface `HttpUpgradeHandler`
    Parameters:
      `webConnection` - The connection that has been upgraded

  - ### processStreamOnContainerThread

    protected void processStreamOnContainerThread(org.apache.coyote.http2.Stream stream)

  - ### decrementActiveRemoteStreamCount

    protected void decrementActiveRemoteStreamCount(org.apache.coyote.http2.Stream stream)

  - ### setSocketWrapper

    public void setSocketWrapper(SocketWrapperBase<?> wrapper)
    Description copied from interface: `InternalHttpUpgradeHandler`
    Associate with the specified socket.
    Specified by:
      `setSocketWrapper` in interface `InternalHttpUpgradeHandler`
    Parameters:
      `wrapper` - the socket

  - ### setSslSupport

    public void setSslSupport(SSLSupport sslSupport)
    Description copied from interface: `InternalHttpUpgradeHandler`
    Associate with the specified SSL support.
    Specified by:
      `setSslSupport` in interface `InternalHttpUpgradeHandler`
    Parameters:
      `sslSupport` - the SSL support

  - ### upgradeDispatch

    public AbstractEndpoint.Handler.SocketState upgradeDispatch(SocketEvent status)
    Description copied from interface: `InternalHttpUpgradeHandler`
    Process the specified event.
    Specified by:
      `upgradeDispatch` in interface `InternalHttpUpgradeHandler`
    Parameters:
      `status` - the event
    Returns:
      the status following the event

  - ### setConnectionTimeoutForStreamCount

    protected void setConnectionTimeoutForStreamCount(int streamCount)

  - ### timeoutAsync

    public void timeoutAsync(long now)
    Description copied from interface: `InternalHttpUpgradeHandler`
    Check for a possible timeout.
    Specified by:
      `timeoutAsync` in interface `InternalHttpUpgradeHandler`
    Parameters:
      `now` - the time to use for the timeout check

  - ### pause

    public void pause()
    Description copied from interface: `InternalHttpUpgradeHandler`
    Pause processing for the connection.
    Specified by:
      `pause` in interface `InternalHttpUpgradeHandler`

  - ### destroy

    public void destroy()
    Description copied from interface: `javax.servlet.http.HttpUpgradeHandler`
    This method is called after the upgraded connection has been closed.
    Specified by:
      `destroy` in interface `HttpUpgradeHandler`

  - ### createWindowUpdateForSettings

    protected byte[] createWindowUpdateForSettings()
    Returns:
      The WINDOW_UPDATE frame if one is required or an empty array if no WINDOW_UPDATE is required.

  - ### doWriteHeaders

    protected org.apache.coyote.http2.Http2UpgradeHandler.HeaderFrameBuffers doWriteHeaders(org.apache.coyote.http2.Stream stream, int pushedStreamId, MimeHeaders mimeHeaders, boolean endOfStream, int payloadSize) throws IOException
    Throws:
      `IOException`

  - ### getHpackEncoder

    protected org.apache.coyote.http2.HpackEncoder getHpackEncoder()

  - ### sentEndOfStream

    protected void sentEndOfStream(org.apache.coyote.http2.Stream stream)

  - ### handleAppInitiatedIOException

    protected void handleAppInitiatedIOException(IOException ioe) throws IOException
    Throws:
      `IOException`

  - ### processWrites

    protected void processWrites() throws IOException
    Throws:
      `IOException`

  - ### incrementWindowSize

    protected void incrementWindowSize(int increment) throws org.apache.coyote.http2.Http2Exception
    Throws:
      `org.apache.coyote.http2.Http2Exception`

  - ### getConnectionId

    protected final String getConnectionId()

  - ### increaseOverheadCount

    public void increaseOverheadCount(org.apache.coyote.http2.FrameType frameType)

  - ### increaseOverheadCount

    protected void increaseOverheadCount(org.apache.coyote.http2.FrameType frameType, int increment)
    Used to increase the overhead for frames that don't use the `overheadCountFactor` (`CONTINUATION`, `DATA`, `WINDOW_UPDATE` and `RESET`).
    Parameters:
      `frameType` - The frame type triggering the overhead increase
      `increment` - The amount by which the overhead is increased

  - ### fill

    public boolean fill(boolean block, byte[] data, int offset, int length) throws IOException
    Throws:
      `IOException`

  - ### getMaxFrameSize

    public int getMaxFrameSize()

  - ### getHpackDecoder

    public HpackDecoder getHpackDecoder()

  - ### startRequestBodyFrame

    public ByteBuffer startRequestBodyFrame(int streamId, int dataLength, boolean endOfStream) throws org.apache.coyote.http2.Http2Exception
    Throws:
      `org.apache.coyote.http2.Http2Exception`

  - ### endRequestBodyFrame

    public void endRequestBodyFrame(int streamId, int dataLength) throws org.apache.coyote.http2.Http2Exception, IOException
    Throws:
      `org.apache.coyote.http2.Http2Exception`
      `IOException`

  - ### onSwallowedDataFramePayload

    public void onSwallowedDataFramePayload(int streamId, int swallowedDataBytesCount) throws IOException
    Throws:
      `IOException`

  - ### headersStart

    public org.apache.coyote.http2.HpackDecoder.HeaderEmitter headersStart(int streamId, boolean headersEndStream) throws org.apache.coyote.http2.Http2Exception, IOException
    Throws:
      `org.apache.coyote.http2.Http2Exception`
      `IOException`

  - ### reprioritise

    @Deprecated public void reprioritise(int streamId, int parentStreamId, boolean exclusive, int weight) throws org.apache.coyote.http2.Http2Exception
    Deprecated.
    Unused. Will be removed in Tomcat 11 onwards.
    Unused - NO-OP.
    Parameters:
      `streamId` - Unused
      `parentStreamId` - Unused
      `exclusive` - Unused
      `weight` - Unused
    Throws:
      `org.apache.coyote.http2.Http2Exception` - Never thrown

  - ### headersContinue

    public void headersContinue(int payloadSize, boolean endOfHeaders)

  - ### headersEnd

    public void headersEnd(int streamId, boolean endOfStream) throws org.apache.coyote.http2.Http2Exception
    Throws:
      `org.apache.coyote.http2.Http2Exception`

  - ### receivedEndOfStream

    public void receivedEndOfStream(int streamId) throws org.apache.coyote.http2.ConnectionException
    Throws:
      `org.apache.coyote.http2.ConnectionException`

  - ### reset

    public void reset(int streamId, long errorCode) throws org.apache.coyote.http2.Http2Exception
    Throws:
      `org.apache.coyote.http2.Http2Exception`

  - ### setting

    public void setting(org.apache.coyote.http2.Setting setting, long value) throws org.apache.coyote.http2.ConnectionException
    Throws:
      `org.apache.coyote.http2.ConnectionException`

  - ### pingReceive

    public void pingReceive(byte[] payload, boolean ack) throws IOException
    Throws:
      `IOException`

  - ### goaway

    public void goaway(int lastStreamId, long errorCode, String debugData)

  - ### incrementWindowSize

    public void incrementWindowSize(int streamId, int increment) throws org.apache.coyote.http2.Http2Exception
    Throws:
      `org.apache.coyote.http2.Http2Exception`

  - ### priorityUpdate

    public void priorityUpdate(int prioritizedStreamID, Priority p) throws org.apache.coyote.http2.Http2Exception
    Throws:
      `org.apache.coyote.http2.Http2Exception`

  - ### onSwallowedUnknownFrame

    public void onSwallowedUnknownFrame(int streamId, int frameTypeId, int flags, int size) throws IOException
    Throws:
      `IOException`

  - ### fill

    default boolean fill(boolean block, byte[] data) throws IOException
    Throws:
      `IOException`

  - ### fill

    default boolean fill(boolean block, ByteBuffer data, int len) throws IOException
    Throws:
      `IOException`