public enum Protocol extends Enum<Protocol>
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.| 枚举常量和说明 |
|---|
H2_PRIOR_KNOWLEDGE
Cleartext HTTP/2 with no "upgrade" round trip.
|
HTTP_1_0
An obsolete plaintext framing that does not use persistent sockets by default.
|
HTTP_1_1
A plaintext framing that includes persistent connections.
|
HTTP_2
The IETF's binary-framed protocol that includes header compression, multiplexing multiple
requests on the same socket, and server-push.
|
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.
|
SPDY_3
已过时。
OkHttp has dropped support for SPDY. Prefer
HTTP_2. |
| 限定符和类型 | 方法和说明 |
|---|---|
static Protocol |
get(String protocol)
Returns the protocol identified by
protocol. |
String |
toString()
Returns the string used to identify this protocol for ALPN, like "http/1.1", "spdy/3.1" or
"h2".
|
static Protocol |
valueOf(String name)
返回带有指定名称的该类型的枚举常量。
|
static Protocol[] |
values()
按照声明该枚举类型的常量的顺序, 返回
包含这些常量的数组。
|
public static final Protocol HTTP_1_0
public static final Protocol HTTP_1_1
This version of OkHttp implements RFC 7230, and tracks revisions to that spec.
public static final Protocol SPDY_3
HTTP_2.Current versions of OkHttp do not support this protocol.
public static final Protocol 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.
public static final Protocol H2_PRIOR_KNOWLEDGE
public static final Protocol QUIC
QUIC is not natively supported by OkHttp, but provided to allow a theoretical interceptor that provides support.
public static Protocol[] values()
for (Protocol c : Protocol.values()) System.out.println(c);
public static Protocol valueOf(String name)
name - 要返回的枚举常量的名称。IllegalArgumentException - 如果该枚举类型没有带有指定名称的常量NullPointerException - 如果参数为空值public static Protocol get(String protocol) throws IOException
protocol.IOException - if protocol is unknown.public String toString()
toString 在类中 Enum<Protocol>Copyright © 2022. All rights reserved.