Interface HttpClientSpi

All Superinterfaces:
ReleasableResource
All Known Implementing Classes:
Http2ClientImpl

public interface HttpClientSpi extends ReleasableResource
Integration for HTTP versions to provide a single API.
  • Method Details

    • supports

      HttpClientSpi.SupportLevel supports(FullClientRequest<?> clientRequest, ClientUri clientUri)
      Return whether this HTTP version can handle the provided request.

      Examples:

      So how can we get to HTTP/2 with prior knowledge, or HTTP/3? There are the following options: Note that this result is cached and revalidated for later requests. Implementations must make this method cheap and safe to invoke repeatedly, including for concurrent requests.
      Parameters:
      clientRequest - HTTP request
      clientUri - URI to invoke
      Returns:
      support level for this protocol and request
    • clientRequest

      ClientRequest<?> clientRequest(FullClientRequest<?> clientRequest, ClientUri clientUri)
      Create a client request based on the provided HTTP request that is for the version of this client.
      Parameters:
      clientRequest - request configuration
      clientUri - URI to invoke (resolved)
      Returns:
      a new request
    • responseReceived

      default void responseReceived(WebClientProtocolResponse response)
      Notification invoked after the WebClient receives a transport response, regardless of the protocol that produced it.

      An implementation may inspect response metadata relevant to its protocol. For example, it may learn about an alternative service from an Alt-Svc response header received over another protocol.

      Parameters:
      response - received protocol response
    • isTcp

      default boolean isTcp()
      For TCP based protocols, we can do ALPN negotiation, obtain a connection, and then let the client handle the protocol. Similar for proxies - we can establish a proxy connection, and then let the client handle the protocol. For UDP based protocols, we need to wait for Alt-Svc headers before attempting anything, or have an explicit version configured.
      Returns:
      whether this is a TCP based HTTP protocol, defaults to true