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.Enum Constant and Description |
---|
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
Deprecated.
OkHttp has dropped support for SPDY. Prefer
HTTP_2 . |
Modifier and Type | Method and Description |
---|---|
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)
Returns the enum constant of this type with the specified name.
|
static Protocol[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
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
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static Protocol get(String protocol) throws IOException
protocol
.IOException
- if protocol
is unknown.public String toString()
toString
in class Enum<Protocol>
Copyright © 2019. All rights reserved.