Class ControlStream

java.lang.Object
org.omegazero.http.h2.streams.HTTP2Stream
org.omegazero.http.h2.streams.ControlStream

public class ControlStream extends HTTP2Stream
Represents the connection HTTP2Stream where frames are exchanged that affect the entire HTTP/2 connection (stream with ID equal to 0).
Since:
1.2.1
  • Constructor Details

  • Method Details

    • sendGoaway

      public void sendGoaway(int highestStreamId, int errorCode)
      Sends a GOAWAY frame with the given stream ID and error code on this control stream.
      Parameters:
      highestStreamId - The last processed stream ID
      errorCode - The error code
    • writeSettings

      public void writeSettings(HTTP2Settings settings)
      Sends a SETTINGS frame with the given HTTP2Settings data on this control stream.

      This method send all setting values that differ from the default value.

      Parameters:
      settings - The settings
      See Also:
    • writeSettings

      public void writeSettings(HTTP2Settings settings, int... settingIds)
      Sends a SETTINGS frame with the given HTTP2Settings data on this control stream.

      This method send all settings with an ID in settingIds.

      Parameters:
      settings - The settings
      settingIds - The IDs of the settings to send
      See Also:
    • receiveFrame

      public void receiveFrame(int type, int flags, byte[] data) throws HTTP2ConnectionError
      Description copied from class: HTTP2Stream
      This method is called if a frame is received on this HTTP/2 stream.
      Overrides:
      receiveFrame in class HTTP2Stream
      Parameters:
      type - The frame type number
      flags - The frame flags
      data - The frame payload
      Throws:
      HTTP2ConnectionError - If a HTTP/2 connection error occurs, for example because the frame payload is invalid
    • windowUpdate

      protected void windowUpdate()
      Description copied from class: HTTP2Stream
      This method is called when a window update frame is received. The HTTP2Stream.receiverWindowSize is updated before this method is called.
      Overrides:
      windowUpdate in class HTTP2Stream
    • setOnSettingsUpdate

      public void setOnSettingsUpdate(Consumer<HTTP2Settings> onSettingsUpdate)
      Sets the callback that is called when a SETTINGS frame is received from the remote endpoint.
      Parameters:
      onSettingsUpdate - The callback
    • setOnWindowUpdate

      public void setOnWindowUpdate(Runnable onWindowUpdate)
      Sets the callback that is called when a WINDOW_UPDATE frame is received from the remote endpoint.
      Parameters:
      onWindowUpdate - The callback
    • isSettingsReceived

      public boolean isSettingsReceived()
      Returns true if a SETTINGS frame was received.
      Returns:
      true if a SETTINGS frame was received
    • getLocalSettings

      public HTTP2Settings getLocalSettings()
      Returns the local HTTP2Settings.
      Returns:
      The local HTTP2Settings
    • getRemoteSettings

      public HTTP2Settings getRemoteSettings()
      Returns the HTTP2Settings sent by the remote endpoint.
      Returns:
      The remote HTTP2Settings
    • getReceiverWindowSize

      public int getReceiverWindowSize()
      Returns the connection window size of the remote endpoint.
      Returns:
      The remote connection window size
    • getLocalWindowSize

      public int getLocalWindowSize()
      Returns the connection window size of the local endpoint.
      Returns:
      The local connection window size
    • consumeReceiverConnectionWindow

      public void consumeReceiverConnectionWindow(int size)
      Reduces the remote's connection window by the given size because a flow-controlled packet is being sent.
      Parameters:
      size - The size of the payload of the flow-controlled packet
    • consumeLocalConnectionWindow

      public void consumeLocalConnectionWindow(int size)
      Reduces the local connection window by the given size because a flow-controlled packet was received.
      Parameters:
      size - The size of the payload of the flow-controlled packet