org.apache.coyote.http2

## Class Http2UpgradeHandler

- java.lang.Object
- - org.apache.coyote.http2.Http2UpgradeHandler

- All Implemented Interfaces:
    HttpUpgradeHandler, InternalHttpUpgradeHandler

      public class Http2UpgradeHandler
      extends Object
      implements InternalHttpUpgradeHandler

  This represents an HTTP/2 connection from a client to Tomcat. It is designed on the basis that there will never be more than one thread performing I/O at a time.
  For reading, this implementation is blocking within frames and non-blocking between frames.
  Note:
  - You will need to nest an <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" /> element inside a TLS enabled Connector element in server.xml to enable HTTP/2 support.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Http2UpgradeHandler(Adapter adapter, Request coyoteRequest)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `decrementWindowSize(int decrement)`
    `void` | `destroy()` This method is called after the upgraded connection has been closed.
    `protected void` | `doNotifyAll()`
    `void` | `endRequestBodyFrame(int streamId)`
    `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.
    `boolean` | `fill(boolean block, ByteBuffer data, int len)`
    `protected String` | `getConnectionId()`
    `HpackDecoder` | `getHpackDecoder()`
    `Integer` | `getIdentifier()`
    `long` | `getKeepAliveTimeout()`
    `int` | `getMaxFrameSize()`
    `int` | `getMaxHeaderCount()`
    `int` | `getMaxHeaderSize()`
    `int` | `getMaxTrailerCount()`
    `int` | `getMaxTrailerSize()`
    `long` | `getReadTimeout()`
    `protected int` | `getWeight()`
    `protected long` | `getWindowSize()`
    `long` | `getWriteTimeout()`
    `void` | `goaway(int lastStreamId, long errorCode, String debugData)`
    `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` | `pause()`
    `void` | `pingReceive(byte[] payload, boolean ack)`
    `void` | `receivedEndOfStream(int streamId)`
    `void` | `reprioritise(int streamId, int parentStreamId, boolean exclusive, int weight)`
    `void` | `reset(int streamId, long errorCode)`
    `void` | `setAllowedTrailerHeaders(Set<String> allowedTrailerHeaders)`
    `void` | `setInitialWindowSize(int initialWindowSize)`
    `void` | `setInitiatePingDisabled(boolean initiatePingDisabled)`
    `void` | `setKeepAliveTimeout(long keepAliveTimeout)`
    `void` | `setMaxConcurrentStreamExecution(int maxConcurrentStreamExecution)`
    `void` | `setMaxConcurrentStreams(long maxConcurrentStreams)`
    `void` | `setMaxHeaderCount(int maxHeaderCount)`
    `void` | `setMaxHeaderSize(int maxHeaderSize)`
    `void` | `setMaxTrailerCount(int maxTrailerCount)`
    `void` | `setMaxTrailerSize(int maxTrailerSize)`
    `void` | `setReadTimeout(long readTimeout)`
    `void` | `setSocketWrapper(SocketWrapperBase<?> wrapper)`
    `void` | `setSslSupport(SSLSupport sslSupport)`
    `void` | `setting(Setting setting, long value)`
    `void` | `settingsEnd(boolean ack)`
    `protected void` | `setWindowSize(long windowSize)`
    `void` | `setWriteTimeout(long writeTimeout)`
    `ByteBuffer` | `startRequestBodyFrame(int streamId, int payloadSize)`
    `void` | `swallowed(int streamId, FrameType frameType, int flags, int size)`
    `void` | `swallowedPadding(int streamId, int paddingLength)`
    `AbstractEndpoint.Handler.SocketState` | `upgradeDispatch(SocketEvent status)`

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### Http2UpgradeHandler

          public Http2UpgradeHandler(Adapter adapter,
                             Request coyoteRequest)

  - ### Method Detail

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

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

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

    - #### incrementWindowSize

          protected void incrementWindowSize(int increment)
                                      throws Http2Exception

      Increment window size.
      Parameters:
        `increment` - The amount of the incrementation
      Throws:
        `Http2Exception` - If the window size is now higher than the maximum allowed

    - #### doNotifyAll

          protected void doNotifyAll()

    - #### getConnectionId

          protected final String getConnectionId()

    - #### getWeight

          protected final int getWeight()

    - #### getReadTimeout

          public long getReadTimeout()

    - #### setReadTimeout

          public void setReadTimeout(long readTimeout)

    - #### getKeepAliveTimeout

          public long getKeepAliveTimeout()

    - #### setKeepAliveTimeout

          public void setKeepAliveTimeout(long keepAliveTimeout)

    - #### getWriteTimeout

          public long getWriteTimeout()

    - #### setWriteTimeout

          public void setWriteTimeout(long writeTimeout)

    - #### setMaxConcurrentStreams

          public void setMaxConcurrentStreams(long maxConcurrentStreams)

    - #### setMaxConcurrentStreamExecution

          public void setMaxConcurrentStreamExecution(int maxConcurrentStreamExecution)

    - #### setInitialWindowSize

          public void setInitialWindowSize(int initialWindowSize)

    - #### setAllowedTrailerHeaders

          public void setAllowedTrailerHeaders(Set<String> allowedTrailerHeaders)

    - #### setMaxHeaderCount

          public void setMaxHeaderCount(int maxHeaderCount)

    - #### getMaxHeaderCount

          public int getMaxHeaderCount()

    - #### setMaxHeaderSize

          public void setMaxHeaderSize(int maxHeaderSize)

    - #### getMaxHeaderSize

          public int getMaxHeaderSize()

    - #### setMaxTrailerCount

          public void setMaxTrailerCount(int maxTrailerCount)

    - #### getMaxTrailerCount

          public int getMaxTrailerCount()

    - #### setMaxTrailerSize

          public void setMaxTrailerSize(int maxTrailerSize)

    - #### getMaxTrailerSize

          public int getMaxTrailerSize()

    - #### setInitiatePingDisabled

          public void setInitiatePingDisabled(boolean initiatePingDisabled)

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

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

      Throws:
        `Http2Exception`

    - #### endRequestBodyFrame

          public void endRequestBodyFrame(int streamId)
                                   throws Http2Exception

      Throws:
        `Http2Exception`

    - #### receivedEndOfStream

          public void receivedEndOfStream(int streamId)
                                   throws ConnectionException

      Throws:
        `ConnectionException`

    - #### swallowedPadding

          public void swallowedPadding(int streamId,
                              int paddingLength)
                                throws ConnectionException,
                                       IOException

      Throws:
        `ConnectionException`
        `IOException`

    - #### headersStart

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

      Throws:
        `Http2Exception`

    - #### reprioritise

          public void reprioritise(int streamId,
                          int parentStreamId,
                          boolean exclusive,
                          int weight)
                            throws Http2Exception

      Throws:
        `Http2Exception`

    - #### headersEnd

          public void headersEnd(int streamId)
                          throws ConnectionException

      Throws:
        `ConnectionException`

    - #### reset

          public void reset(int streamId,
                   long errorCode)
                     throws Http2Exception

      Throws:
        `Http2Exception`

    - #### setting

          public void setting(Setting setting,
                     long value)
                       throws ConnectionException

      Throws:
        `ConnectionException`

    - #### settingsEnd

          public void settingsEnd(boolean ack)
                           throws IOException

      Throws:
        `IOException`

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

      Throws:
        `Http2Exception`

    - #### swallowed

          public void swallowed(int streamId,
                       FrameType frameType,
                       int flags,
                       int size)
                         throws IOException

      Throws:
        `IOException`

    - #### getIdentifier

          public Integer getIdentifier()

    - #### setWindowSize

          protected void setWindowSize(long windowSize)

    - #### getWindowSize

          protected long getWindowSize()

    - #### decrementWindowSize

          protected void decrementWindowSize(int decrement)

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