Package com.squareup.okhttp
Class Connection
- java.lang.Object
-
- com.squareup.okhttp.Connection
-
public final class Connection extends Object
The sockets and streams of an HTTP, HTTPS, or HTTPS+SPDY connection. May be used for multiple HTTP request/response exchanges. Connections may be direct to the origin server or via a proxy.Typically instances of this class are created, connected and exercised automatically by the HTTP client. Applications may use this class to monitor HTTP connections as members of a connection pool.
Do not confuse this class with the misnamed
HttpURLConnection, which isn't so much a connection as a single request/response exchange.Modern TLS
There are tradeoffs when selecting which options to include when negotiating a secure connection to a remote host. Newer TLS options are quite useful:- Server Name Indication (SNI) enables one IP address to negotiate secure connections for multiple domain names.
- Application Layer Protocol Negotiation (ALPN) enables the HTTPS port (443) to be used for different HTTP and SPDY protocols.
-
-
Constructor Summary
Constructors Constructor Description Connection(ConnectionPool pool, Route route)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HandshakegetHandshake()ProtocolgetProtocol()Returns the protocol negotiated by this connection, orProtocol.HTTP_1_1if no protocol has been negotiated.RoutegetRoute()Returns the route used by this connection.SocketgetSocket()Returns the socket that this connection uses, or null if the connection is not currently connected.StringtoString()Returns a string containing a concise, human-readable description of this object.
-
-
-
Constructor Detail
-
Connection
public Connection(ConnectionPool pool, Route route)
-
-
Method Detail
-
getRoute
public Route getRoute()
Returns the route used by this connection.
-
getSocket
public Socket getSocket()
Returns the socket that this connection uses, or null if the connection is not currently connected.
-
getHandshake
public Handshake getHandshake()
-
getProtocol
public Protocol getProtocol()
Returns the protocol negotiated by this connection, orProtocol.HTTP_1_1if no protocol has been negotiated.
-
toString
public String toString()
Description copied from class:ObjectReturns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toStringmethod if you intend implementing your owntoStringmethod.
-
-