Interface HttpUpgrader

All Known Implementing Classes:
HttpUpgraderOverHTTP, HttpUpgraderOverHTTP2, ProtocolHttpUpgrader

public interface HttpUpgrader

HttpUpgrader prepares a HTTP request to upgrade from one protocol to another, and implements the upgrade mechanism.

The upgrade mechanism can be the HTTP/1.1 upgrade mechanism or the HTTP/2 extended CONNECT mechanism.

Given the differences among mechanism implementations, a request needs to be prepared before being sent to comply with the mechanism requirements (for example, add required headers, etc.).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A factory for HttpUpgraders.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The request attribute key for the upgrade protocol, used by the HTTP/2 extended CONNECT mechanism.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    prepare(Request request)
    Prepares the request for the upgrade, for example by setting the HTTP method or by setting HTTP headers required for the upgrade.
    void
    upgrade(Response response, EndPoint endPoint, Callback callback)
    Upgrades the given endPoint to a different protocol.
  • Field Details

    • PROTOCOL_ATTRIBUTE

      static final String PROTOCOL_ATTRIBUTE

      The request attribute key for the upgrade protocol, used by the HTTP/2 extended CONNECT mechanism.

  • Method Details

    • prepare

      void prepare(Request request)

      Prepares the request for the upgrade, for example by setting the HTTP method or by setting HTTP headers required for the upgrade.

      Parameters:
      request - the request to prepare
    • upgrade

      void upgrade(Response response, EndPoint endPoint, Callback callback)

      Upgrades the given endPoint to a different protocol.

      The success or failure of the upgrade should be communicated via the given callback.

      An exception thrown by this method is equivalent to failing the callback.

      Parameters:
      response - the response with the information about the upgrade
      endPoint - the EndPoint to upgrade
      callback - a callback to notify of the success or failure of the upgrade