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 |
---|
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.
|
SPDY_3
Chromium's binary-framed protocol that includes header compression,
multiplexing multiple requests on the same socket, and server-push.
|
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 2616, and tracks revisions to that spec.
public static final Protocol SPDY_3
This version of OkHttp implements SPDY 3 draft 3.1. Future releases of OkHttp may use this identifier for a newer draft of the SPDY spec.
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 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.Copyright © 2016. All Rights Reserved.