Module bus.http

Interface Connection

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 Type
    Method
    Description
    Returns the TLS handshake used to establish this connection, or null if the connection is not HTTPS.
    org.miaixz.bus.core.net.Protocol
    Returns the protocol negotiated by this connection, or Protocol.HTTP_1_1 if no protocol was negotiated.
    Returns the route that this connection follows.
    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 an SSLSocket. 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, or Protocol.HTTP_1_1 if no protocol was negotiated. This method returns Protocol.HTTP_1_1 even if the remote peer is using Protocol.HTTP_1_0.
      Returns:
      The negotiated protocol.