org.apache.coyote.http2

## 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 and Description
    --- | ---
    `protected class` | `Http2AsyncUpgradeHandler.AsyncPingManager`
    `protected class` | `Http2AsyncUpgradeHandler.SendfileCompletionHandler`
    `protected static interface` | `Http2UpgradeHandler.HeaderFrameBuffers`
    `protected static class` | `Http2UpgradeHandler.PingRecord`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AtomicInteger` | `activeRemoteStreamCount`
    `protected String` | `connectionId`
    `protected static int` | `FLAG_END_OF_HEADERS`
    `protected static int` | `FLAG_END_OF_STREAM`
    `protected static byte[]` | `GOAWAY`
    `protected 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 Log` | `log`
    `protected static byte[]` | `PING`
    `protected static byte[]` | `PING_ACK`
    `protected Http2Protocol` | `protocol`
    `protected static byte[]` | `SETTINGS_ACK`
    `protected static StringManager` | `sm`
    `protected SocketWrapperBase<?>` | `socketWrapper`

  - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected byte[]` | `createWindowUpdateForSettings()`
    `void` | `destroy()` This method is called after the upgraded connection has been closed.
    `protected 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)` Fill the given array with data unless non-blocking is requested and no data is available.
    `default boolean` | `fill(boolean block, ByteBuffer data, int len)`
    `protected String` | `getConnectionId()`
    `protected 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()`
    `protected int` | `getWeight()`
    `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)`
    `org.apache.coyote.http2.HpackDecoder.HeaderEmitter` | `headersStart(int streamId, boolean headersEndStream)`
    `protected void` | `incrementWindowSize(int increment)` Increment window size.
    `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)` Notification triggered when the parser swallows some or all of a DATA frame payload without writing it to the ByteBuffer returned by `startRequestBodyFrame(int, int, boolean)`.
    `void` | `onSwallowedUnknownFrame(int streamId, int frameTypeId, int flags, int size)` Notification triggered when the parser swallows the payload of an unknown frame.
    `void` | `pause()`
    `void` | `pingReceive(byte[] payload, boolean ack)`
    `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)`
    `void` | `reset(int streamId, long errorCode)`
    `protected void` | `setConnectionTimeoutForStreamCount(int streamCount)`
    `void` | `setSocketWrapper(SocketWrapperBase<?> wrapper)`
    `void` | `setSslSupport(SSLSupport sslSupport)`
    `void` | `setting(org.apache.coyote.http2.Setting setting, long value)`
    `void` | `settingsEnd(boolean ack)`
    `ByteBuffer` | `startRequestBodyFrame(int streamId, int payloadSize, boolean endOfStream)`
    `void` | `timeoutAsync(long now)`
    `AbstractEndpoint.Handler.SocketState` | `upgradeDispatch(SocketEvent status)`
    `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 java.lang.Object

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

    - ### Methods inherited from interface org.apache.coyote.http11.upgrade.InternalHttpUpgradeHandler

      `getUpgradeInfo`

- - ### Field Detail

    - #### 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

    - #### 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

  - ### Constructor Detail

    - #### Http2AsyncUpgradeHandler

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

  - ### Method Detail

    - #### getParser

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

    - #### getPingManager

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

    - #### hasAsyncIO

          public boolean hasAsyncIO()

    - #### 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 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)

    - #### setSocketWrapper

          public void setSocketWrapper(SocketWrapperBase<?> wrapper)

      Specified by:
        `setSocketWrapper` in interface `InternalHttpUpgradeHandler`

    - #### setSslSupport

          public void setSslSupport(SSLSupport sslSupport)

      Specified by:
        `setSslSupport` in interface `InternalHttpUpgradeHandler`

    - #### upgradeDispatch

          public AbstractEndpoint.Handler.SocketState upgradeDispatch(SocketEvent status)

      Specified by:
        `upgradeDispatch` in interface `InternalHttpUpgradeHandler`

    - #### setConnectionTimeoutForStreamCount

          protected void setConnectionTimeoutForStreamCount(int streamCount)

    - #### timeoutAsync

          public void timeoutAsync(long now)

      Specified by:
        `timeoutAsync` in interface `InternalHttpUpgradeHandler`

    - #### pause

          public void pause()

      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 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()

    - #### 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

      Increment window size.
      Parameters:
        `increment` - The amount by which the window size should be increased
      Throws:
        `Http2Exception` - If the window size is now higher than the maximum allowed

    - #### getConnectionId

          protected final String getConnectionId()

    - #### getWeight

          protected final int getWeight()

    - #### fill

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

      Fill the given array with data unless non-blocking is requested and no data is available. If any data is available then the buffer will be filled using blocking I/O.
      Parameters:
        `block` - Should the first read into the provided buffer be a blocking read or not.
        `data` - Buffer to fill
        `offset` - Position in buffer to start writing
        `length` - Number of bytes to read
      Returns:
        `true` if the buffer was filled otherwise `false`
      Throws:
        `IOException` - If an I/O occurred while obtaining data with which to fill the buffer

    - #### getMaxFrameSize

          public int getMaxFrameSize()

    - #### getHpackDecoder

          public HpackDecoder getHpackDecoder()

    - #### startRequestBodyFrame

          public ByteBuffer startRequestBodyFrame(int streamId,
                                                  int payloadSize,
                                                  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`

    - #### receivedEndOfStream

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

      Throws:
        `org.apache.coyote.http2.ConnectionException`

    - #### onSwallowedDataFramePayload

          public void onSwallowedDataFramePayload(int streamId,
                                                  int swallowedDataBytesCount)
                                           throws IOException

      Notification triggered when the parser swallows some or all of a DATA frame payload without writing it to the ByteBuffer returned by `startRequestBodyFrame(int, int, boolean)`.
      Parameters:
        `streamId` - The stream on which the payload that has been swallowed was received
        `swallowedDataBytesCount` - The number of bytes that the parser swallowed.
      Throws:
        `IOException` - If an I/O occurred while swallowing the payload

    - #### 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

          public void reprioritise(int streamId,
                                   int parentStreamId,
                                   boolean exclusive,
                                   int weight)
                            throws org.apache.coyote.http2.Http2Exception

      Throws:
        `org.apache.coyote.http2.Http2Exception`

    - #### headersContinue

          public void headersContinue(int payloadSize,
                                      boolean endOfHeaders)

    - #### headersEnd

          public void headersEnd(int streamId)
                          throws org.apache.coyote.http2.Http2Exception

      Throws:
        `org.apache.coyote.http2.Http2Exception`

    - #### 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`

    - #### onSwallowedUnknownFrame

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

      Notification triggered when the parser swallows the payload of an unknown frame.
      Parameters:
        `streamId` - The stream on which the swallowed frame was received
        `frameTypeId` - The (unrecognised) type of swallowed frame
        `flags` - The flags set in the header of the swallowed frame
        `size` - The payload size of the swallowed frame
      Throws:
        `IOException` - If an I/O occurred while swallowing the unknown frame

    - #### fill

          public boolean fill(boolean block,
                              byte[] data)
                       throws IOException

      Throws:
        `IOException`

    - #### fill

          public boolean fill(boolean block,
                              ByteBuffer data,
                              int len)
                       throws IOException

      Throws:
        `IOException`

Copyright © 2000-2022 Apache Software Foundation. All Rights Reserved.