- All Known Implementing Classes:
RealConnection
public interface Connection
The socket and streams of an HTTP, HTTPS, or HTTPS+HTTP/2 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.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Method Summary
Modifier and TypeMethodDescriptionReturns the TLS handshake used to establish this connection, or null if the connection is not HTTPS.org.miaixz.bus.core.net.Protocolprotocol()Returns the protocol negotiated by this connection, orProtocol.HTTP_1_1if no protocol was negotiated.route()Returns the route that this connection follows.socket()Returns the socket that this connection uses.
-
Method Details
-
route
Route route()Returns the route that this connection follows.- Returns:
- The route of this connection.
-
socket
Socket socket()Returns the socket that this connection uses. If this connection is HTTPS, this is anSSLSocket. If this is an HTTP/2 connection the socket may be shared by multiple concurrent calls.- Returns:
- The socket for this connection.
-
handshake
Handshake handshake()Returns the TLS handshake used to establish this connection, or null if the connection is not HTTPS.- Returns:
- The TLS handshake, or null.
-
protocol
org.miaixz.bus.core.net.Protocol protocol()Returns the protocol negotiated by this connection, orProtocol.HTTP_1_1if no protocol was negotiated. This method returnsProtocol.HTTP_1_1even if the remote peer is usingProtocol.HTTP_1_0.- Returns:
- The negotiated protocol.
-