枚举类 Protocol

java.lang.Object
java.lang.Enum<Protocol>
com.lark.oapi.okhttp.Protocol
所有已实现的接口:
Serializable, Comparable<Protocol>, java.lang.constant.Constable

public enum Protocol extends Enum<Protocol>
Protocols that OkHttp implements for ALPN selection.

Protocol vs Scheme

Despite its name, URL.getProtocol() returns the scheme (http, https, etc.) of the URL, not the protocol (http/1.1, spdy/3.1, etc.). OkHttp uses the word protocol to identify how HTTP messages are framed.
  • 嵌套类概要

    从类继承的嵌套类/接口 java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • 枚举常量概要

    枚举常量
    枚举常量
    说明
    Cleartext HTTP/2 with no "upgrade" round trip.
    An obsolete plaintext framing that does not use persistent sockets by default.
    A plaintext framing that includes persistent connections.
    The IETF's binary-framed protocol that includes header compression, multiplexing multiple requests on the same socket, and server-push.
    QUIC (Quick UDP Internet Connection) is a new multiplexed and secure transport atop UDP, designed from the ground up and optimized for HTTP/2 semantics.
    已过时。
    OkHttp has dropped support for SPDY.
  • 方法概要

    修饰符和类型
    方法
    说明
    static Protocol
    get(String protocol)
    Returns the protocol identified by protocol.
    Returns the string used to identify this protocol for ALPN, like "http/1.1", "spdy/3.1" or "h2".
    static Protocol
    返回带有指定名称的该类的枚举常量。
    static Protocol[]
    返回包含该枚举类的常量的数组, 顺序与声明这些常量的顺序相同

    从类继承的方法 java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • 枚举常量详细资料

    • HTTP_1_0

      public static final Protocol HTTP_1_0
      An obsolete plaintext framing that does not use persistent sockets by default.
    • HTTP_1_1

      public static final Protocol HTTP_1_1
      A plaintext framing that includes persistent connections.

      This version of OkHttp implements RFC 7230, and tracks revisions to that spec.

    • SPDY_3

      public static final Protocol SPDY_3
      已过时。
      OkHttp has dropped support for SPDY. Prefer HTTP_2.
      Chromium's binary-framed protocol that includes header compression, multiplexing multiple requests on the same socket, and server-push. HTTP/1.1 semantics are layered on SPDY/3.

      Current versions of OkHttp do not support this protocol.

    • HTTP_2

      public static final Protocol HTTP_2
      The IETF's binary-framed protocol that includes header compression, multiplexing multiple requests on the same socket, and server-push. HTTP/1.1 semantics are layered on HTTP/2.

      HTTP/2 requires deployments of HTTP/2 that use TLS 1.2 support CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 , present in Java 8+ and Android 5+. Servers that enforce this may send an exception message including the string INADEQUATE_SECURITY.

    • H2_PRIOR_KNOWLEDGE

      public static final Protocol H2_PRIOR_KNOWLEDGE
      Cleartext HTTP/2 with no "upgrade" round trip. This option requires the client to have prior knowledge that the server supports cleartext HTTP/2.
      另请参阅:
    • QUIC

      public static final Protocol QUIC
      QUIC (Quick UDP Internet Connection) is a new multiplexed and secure transport atop UDP, designed from the ground up and optimized for HTTP/2 semantics. HTTP/1.1 semantics are layered on HTTP/2.

      QUIC is not natively supported by OkHttp, but provided to allow a theoretical interceptor that provides support.

  • 方法详细资料

    • values

      public static Protocol[] values()
      返回包含该枚举类的常量的数组, 顺序与声明这些常量的顺序相同
      返回:
      包含该枚举类的常量的数组,顺序与声明这些常量的顺序相同
    • valueOf

      public static Protocol valueOf(String name)
      返回带有指定名称的该类的枚举常量。 字符串必须与用于声明该类的枚举常量的 标识符完全匹配。(不允许有多余 的空格字符。)
      参数:
      name - 要返回的枚举常量的名称。
      返回:
      返回带有指定名称的枚举常量
      抛出:
      IllegalArgumentException - 如果该枚举类没有带有指定名称的常量
      NullPointerException - 如果参数为空值
    • get

      public static Protocol get(String protocol) throws IOException
      Returns the protocol identified by protocol.
      抛出:
      IOException - if protocol is unknown.
    • toString

      public String toString()
      Returns the string used to identify this protocol for ALPN, like "http/1.1", "spdy/3.1" or "h2".
      覆盖:
      toString 在类中 Enum<Protocol>
      另请参阅: