Class Http2ClientImpl

java.lang.Object
io.helidon.webclient.http2.Http2ClientImpl
All Implemented Interfaces:
RuntimeType.Api<Http2ClientConfig>, HttpClient<Http2ClientRequest>, ReleasableResource, Http2Client, HttpClientSpi

public class Http2ClientImpl extends Object implements Http2Client, HttpClientSpi
Implementation of HTTP2 client.
  • Method Details

    • method

      public Http2ClientRequest method(Method method)
      Description copied from interface: HttpClient
      Create a request for a method.
      Specified by:
      method in interface HttpClient<Http2ClientRequest>
      Parameters:
      method - HTTP method
      Returns:
      a new request (not thread safe)
    • prototype

      public Http2ClientConfig prototype()
      Description copied from interface: RuntimeType.Api
      The prototype as it was received when creating this runtime object instance.
      Specified by:
      prototype in interface RuntimeType.Api<Http2ClientConfig>
      Returns:
      prototype object used to create this instance
    • supports

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

      Examples:

      • HTTP/1.1 always returns true, as it is the fallback protocol of all other protocols
      • HTTP/2 returns true when upgrade is enabled, false when prior-knowledge is specified (as we can always attempt to upgrade and fallback to 1.1 in the first case, but we would fail with prior-knowledge, unless the endpoint is known to be HTTP/2
      • HTTP/3 would always return true, as it cannot fallback once a connection is attempted
      So how can we get to HTTP/2 with prior knowledge, or HTTP/3? There are the following options:
      • An explicit protocol id is configured for the request - HttpClientRequest.protocolId(String)
      • There is no fallback protocol enabled, in such a case, we use the one with highest priority - see WebClientConfig.BuilderBase.addProtocolPreference(String)
      • We get an Alt-Svc header from a response that points us to a protocol version (we only support permanent protocol changes, Alt-Svc with timeout will be ignored
      • This protocol version already handled a request to such an endpoint and has the connection available
      Note that this response is cached.
      Specified by:
      supports in interface HttpClientSpi
      Parameters:
      clientRequest - HTTP request
      clientUri - URI to invoke
      Returns:
      true if we are sure we can handle this request with this protocol version
    • clientRequest

      public ClientRequest<?> clientRequest(FullClientRequest<?> clientRequest, ClientUri clientUri)
      Description copied from interface: HttpClientSpi
      Create a client request based on the provided HTTP request that is for the version of this client.
      Specified by:
      clientRequest in interface HttpClientSpi
      Parameters:
      clientRequest - request configuration
      clientUri - URI to invoke (resolved)
      Returns:
      a new request
    • closeResource

      public void closeResource()
      Description copied from interface: HttpClient
      Gracefully close all opened client specific connections.
      Specified by:
      closeResource in interface HttpClient<Http2ClientRequest>
      Specified by:
      closeResource in interface ReleasableResource