Package com.squareup.okhttp
Enum Protocol
- java.lang.Object
-
- java.lang.Enum<Protocol>
-
- com.squareup.okhttp.Protocol
-
- All Implemented Interfaces:
Serializable,Comparable<Protocol>
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.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description HTTP_1_0An obsolete plaintext framing that does not use persistent sockets by default.HTTP_1_1A plaintext framing that includes persistent connections.HTTP_2The IETF's binary-framed protocol that includes header compression, multiplexing multiple requests on the same socket, and server-push.SPDY_3Chromium's binary-framed protocol that includes header compression, multiplexing multiple requests on the same socket, and server-push.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Protocolget(String protocol)Returns the protocol identified byprotocol.StringtoString()Returns the string used to identify this protocol for ALPN, like "http/1.1", "spdy/3.1" or "h2".static ProtocolvalueOf(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.
-
-
-
Enum Constant Detail
-
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 2616, and tracks revisions to that spec.
-
SPDY_3
public static final Protocol SPDY_3
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.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.
-
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.
-
-
Method Detail
-
values
public static Protocol[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Protocol c : Protocol.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Protocol valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
get
public static Protocol get(String protocol) throws IOException
Returns the protocol identified byprotocol.- Throws:
IOException- ifprotocolis unknown.
-
-