Class HttpClientConfig.BuilderBase<BUILDER extends HttpClientConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends HttpClientConfig>

java.lang.Object
io.helidon.webclient.api.HttpConfigBase.BuilderBase<BUILDER,PROTOTYPE>
io.helidon.webclient.api.HttpClientConfig.BuilderBase<BUILDER,PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER,PROTOTYPE>, Prototype.ConfiguredBuilder<BUILDER,PROTOTYPE>
Direct Known Subclasses:
GrpcClientConfig.BuilderBase, Http1ClientConfig.BuilderBase, Http2ClientConfig.BuilderBase, HttpClientConfig.Builder, WebClientConfig.BuilderBase, WsClientConfig.BuilderBase
Enclosing interface:
HttpClientConfig

public abstract static class HttpClientConfig.BuilderBase<BUILDER extends HttpClientConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends HttpClientConfig> extends HttpConfigBase.BuilderBase<BUILDER,PROTOTYPE> implements Prototype.ConfiguredBuilder<BUILDER,PROTOTYPE>
Fluent API builder base for HttpClientConfig.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(HttpClientConfig prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(HttpClientConfig.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • baseUri

      public BUILDER baseUri(URI baseUri)
      Base URI of the client.
      Parameters:
      baseUri - base URI to use, query is extracted to base query (if any)
      Returns:
      updated builder instance
    • baseUri

      public BUILDER baseUri(String baseUri)
      Base URI of the client.
      Parameters:
      baseUri - base URI to use, query is extracted to base query (if any)
      Returns:
      updated builder instance
    • addHeader

      public BUILDER addHeader(HeaderName name, String value)
      Add a default header value.
      Parameters:
      name - name of the header
      value - value of the header
      Returns:
      updated builder instance
    • addHeader

      public BUILDER addHeader(HeaderName name, int value)
      Add a default header value.
      Parameters:
      name - name of the header
      value - value of the header
      Returns:
      updated builder instance
    • addHeader

      public BUILDER addHeader(HeaderName name, long value)
      Add a default header value.
      Parameters:
      name - name of the header
      value - value of the header
      Returns:
      updated builder instance
    • addHeader

      public BUILDER addHeader(String name, String value)
      Add default header value. This method is not optimal and should only be used when the header name is really obtained from a string, in other cases, use an alternative with HeaderName or Header.
      Parameters:
      name - name of the header
      value - value of the header
      Returns:
      updated builder instance
      See Also:
    • addHeader

      public BUILDER addHeader(String name, int value)
      Add default header value. This method is not optimal and should only be used when the header name is really obtained from a string, in other cases, use an alternative with HeaderName or Header.
      Parameters:
      name - name of the header
      value - value of the header
      Returns:
      updated builder instance
      See Also:
    • addHeader

      public BUILDER addHeader(String name, long value)
      Add default header value. This method is not optimal and should only be used when the header name is really obtained from a string, in other cases, use an alternative with HeaderName or Header.
      Parameters:
      name - name of the header
      value - value of the header
      Returns:
      updated builder instance
      See Also:
    • config

      public BUILDER config(Config config)
      Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.
      Specified by:
      config in interface Prototype.ConfiguredBuilder<BUILDER extends HttpClientConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends HttpClientConfig>
      Overrides:
      config in class HttpConfigBase.BuilderBase<BUILDER extends HttpClientConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends HttpClientConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • clearBaseUri

      public BUILDER clearBaseUri()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • baseUri

      public BUILDER baseUri(ClientUri baseUri)
      Base uri used by the client in all requests.
      Parameters:
      baseUri - base uri of the client requests
      Returns:
      updated builder instance
      See Also:
    • baseUri

      public BUILDER baseUri(Config baseUriConfig)
      Base uri used by the client in all requests.
      Parameters:
      baseUriConfig - base uri of the client requests
      Returns:
      updated builder instance
      See Also:
    • clearBaseQuery

      public BUILDER clearBaseQuery()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • baseQuery

      public BUILDER baseQuery(UriQuery baseQuery)
      Base query used by the client in all requests.
      Parameters:
      baseQuery - base query of the client requests
      Returns:
      updated builder instance
      See Also:
    • clearBaseFragment

      public BUILDER clearBaseFragment()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • baseFragment

      public BUILDER baseFragment(UriFragment baseFragment)
      Base fragment used by the client in all requests (unless overwritten on per-request basis).
      Parameters:
      baseFragment - fragment to use
      Returns:
      updated builder instance
      See Also:
    • socketOptions

      public BUILDER socketOptions(SocketOptions socketOptions)
      Socket options for connections opened by this client. If there is a value explicitly configured on this type and on the socket options, the one configured on this type's builder will win:
      Parameters:
      socketOptions - socket options
      Returns:
      updated builder instance
      See Also:
    • socketOptions

      public BUILDER socketOptions(Consumer<SocketOptions.Builder> consumer)
      Socket options for connections opened by this client. If there is a value explicitly configured on this type and on the socket options, the one configured on this type's builder will win:
      Parameters:
      consumer - consumer of builder for socket options
      Returns:
      updated builder instance
      See Also:
    • socketOptions

      public BUILDER socketOptions(Supplier<? extends SocketOptions> supplier)
      Socket options for connections opened by this client. If there is a value explicitly configured on this type and on the socket options, the one configured on this type's builder will win:
      Parameters:
      supplier - supplier of socket options
      Returns:
      updated builder instance
      See Also:
    • dnsResolver

      public BUILDER dnsResolver(DnsResolver dnsResolver)
      DNS resolver to be used by this client.
      Parameters:
      dnsResolver - dns resolver
      Returns:
      updated builder instance
      See Also:
    • dnsAddressLookup

      public BUILDER dnsAddressLookup(DnsAddressLookup dnsAddressLookup)
      DNS address lookup preferences to be used by this client. Default value is determined by capabilities of the system.
      Parameters:
      dnsAddressLookup - dns address lookup strategy
      Returns:
      updated builder instance
      See Also:
    • defaultHeadersMap

      public BUILDER defaultHeadersMap(Map<? extends String,? extends String> defaultHeadersMap)
      This method replaces all values with the new ones.
      Parameters:
      defaultHeadersMap - default headers
      Returns:
      updated builder instance
      See Also:
    • addDefaultHeadersMap

      public BUILDER addDefaultHeadersMap(Map<? extends String,? extends String> defaultHeadersMap)
      This method keeps existing values, then puts all new values into the map.
      Parameters:
      defaultHeadersMap - default headers
      Returns:
      updated builder instance
      See Also:
    • headers

      public BUILDER headers(Set<? extends Header> headers)
      Default headers to be used in every request.
      Parameters:
      headers - default headers
      Returns:
      updated builder instance
      See Also:
    • addHeaders

      public BUILDER addHeaders(Set<? extends Header> headers)
      Default headers to be used in every request.
      Parameters:
      headers - default headers
      Returns:
      updated builder instance
      See Also:
    • addHeader

      public BUILDER addHeader(Header header)
      Default headers to be used in every request.
      Parameters:
      header - default headers
      Returns:
      updated builder instance
      See Also:
    • mediaTypeParserMode

      public BUILDER mediaTypeParserMode(ParserMode mediaTypeParserMode)
      Configure media type parsing mode for HTTP Content-Type header.
      Parameters:
      mediaTypeParserMode - media type parsing mode
      Returns:
      updated builder instance
      See Also:
    • contentEncoding

      public BUILDER contentEncoding(ContentEncodingContext contentEncoding)
      Configure the listener specific ContentEncodingContext. This method discards all previously registered ContentEncodingContext. If no content encoding context is registered, default encoding context is used.
      Parameters:
      contentEncoding - content encoding context
      Returns:
      updated builder instance
      See Also:
    • contentEncoding

      public BUILDER contentEncoding(ContentEncodingContextConfig contentEncodingConfig)
      Configure the listener specific ContentEncodingContext. This method discards all previously registered ContentEncodingContext. If no content encoding context is registered, default encoding context is used.
      Parameters:
      contentEncodingConfig - content encoding context
      Returns:
      updated builder instance
      See Also:
    • contentEncoding

      public BUILDER contentEncoding(Consumer<ContentEncodingContextConfig.Builder> consumer)
      Configure the listener specific ContentEncodingContext. This method discards all previously registered ContentEncodingContext. If no content encoding context is registered, default encoding context is used.
      Parameters:
      consumer - consumer of builder for content encoding context
      Returns:
      updated builder instance
      See Also:
    • contentEncoding

      public BUILDER contentEncoding(Supplier<? extends ContentEncodingContext> supplier)
      Configure the listener specific ContentEncodingContext. This method discards all previously registered ContentEncodingContext. If no content encoding context is registered, default encoding context is used.
      Parameters:
      supplier - supplier of content encoding context
      Returns:
      updated builder instance
      See Also:
    • mediaContext

      public BUILDER mediaContext(MediaContext mediaContext)
      Configure the listener specific MediaContext. This method discards all previously registered MediaContext. If no media context is registered, default media context is used.
      Parameters:
      mediaContext - media context
      Returns:
      updated builder instance
      See Also:
    • mediaContext

      public BUILDER mediaContext(MediaContextConfig mediaContextConfig)
      Configure the listener specific MediaContext. This method discards all previously registered MediaContext. If no media context is registered, default media context is used.
      Parameters:
      mediaContextConfig - media context
      Returns:
      updated builder instance
      See Also:
    • mediaContext

      public BUILDER mediaContext(Consumer<MediaContextConfig.Builder> consumer)
      Configure the listener specific MediaContext. This method discards all previously registered MediaContext. If no media context is registered, default media context is used.
      Parameters:
      consumer - consumer of builder for media context
      Returns:
      updated builder instance
      See Also:
    • mediaContext

      public BUILDER mediaContext(Supplier<? extends MediaContext> supplier)
      Configure the listener specific MediaContext. This method discards all previously registered MediaContext. If no media context is registered, default media context is used.
      Parameters:
      supplier - supplier of media context
      Returns:
      updated builder instance
      See Also:
    • mediaSupports

      public BUILDER mediaSupports(List<? extends MediaSupport> mediaSupports)
      Media supports (manually added). If both mediaContext() and this is configured, there will be a new context created from return of this method, with fallback of mediaContext().
      Parameters:
      mediaSupports - list of explicitly added media supports
      Returns:
      updated builder instance
      See Also:
    • addMediaSupports

      public BUILDER addMediaSupports(List<? extends MediaSupport> mediaSupports)
      Media supports (manually added). If both mediaContext() and this is configured, there will be a new context created from return of this method, with fallback of mediaContext().
      Parameters:
      mediaSupports - list of explicitly added media supports
      Returns:
      updated builder instance
      See Also:
    • addMediaSupport

      public BUILDER addMediaSupport(MediaSupport mediaSupport)
      Media supports (manually added). If both mediaContext() and this is configured, there will be a new context created from return of this method, with fallback of mediaContext().
      Parameters:
      mediaSupport - list of explicitly added media supports
      Returns:
      updated builder instance
      See Also:
    • servicesDiscoverServices

      public BUILDER servicesDiscoverServices(boolean discoverServices)
      WebClient services.
      Parameters:
      discoverServices - whether to discover implementations through service loader
      Returns:
      updated builder instance
      See Also:
    • services

      public BUILDER services(List<? extends WebClientService> services)
      WebClient services.
      Parameters:
      services - services to use with this web client
      Returns:
      updated builder instance
      See Also:
    • addServices

      public BUILDER addServices(List<? extends WebClientService> services)
      WebClient services.
      Parameters:
      services - services to use with this web client
      Returns:
      updated builder instance
      See Also:
    • addService

      public BUILDER addService(WebClientService service)
      WebClient services.
      Parameters:
      service - services to use with this web client
      Returns:
      updated builder instance
      See Also:
    • relativeUris

      public BUILDER relativeUris(boolean relativeUris)
      Can be set to true to force the use of relative URIs in all requests, regardless of the presence or absence of proxies or no-proxy lists.
      Parameters:
      relativeUris - relative URIs flag
      Returns:
      updated builder instance
      See Also:
    • executor

      public BUILDER executor(ExecutorService executor)
      Client executor service.
      Parameters:
      executor - executor service to use when needed (such as for HTTP/2)
      Returns:
      updated builder instance
      See Also:
    • sendExpectContinue

      public BUILDER sendExpectContinue(boolean sendExpectContinue)
      Whether Expect-100-Continue header is sent to verify server availability before sending an entity.

      Defaults to true.

      Parameters:
      sendExpectContinue - whether Expect:100-Continue header should be sent on streamed transfers
      Returns:
      updated builder instance
      See Also:
    • connectionCacheSize

      public BUILDER connectionCacheSize(int connectionCacheSize)
      Maximal size of the connection cache. For most HTTP protocols, we may cache connections to various endpoints for keep alive (or stream reuse in case of HTTP/2). This option limits the size. Setting this number lower than the "usual" number of target services will cause connections to be closed and reopened frequently.
      Parameters:
      connectionCacheSize -
      Returns:
      updated builder instance
      See Also:
    • clearCookieManager

      public BUILDER clearCookieManager()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • cookieManager

      public BUILDER cookieManager(WebClientCookieManager cookieManager)
      WebClient cookie manager.
      Parameters:
      cookieManager - cookie manager to use
      Returns:
      updated builder instance
      See Also:
    • cookieManager

      public BUILDER cookieManager(WebClientCookieManagerConfig cookieManagerConfig)
      WebClient cookie manager.
      Parameters:
      cookieManagerConfig - cookie manager to use
      Returns:
      updated builder instance
      See Also:
    • cookieManager

      public BUILDER cookieManager(Consumer<WebClientCookieManagerConfig.Builder> consumer)
      WebClient cookie manager.
      Parameters:
      consumer - cookie manager to use
      Returns:
      updated builder instance
      See Also:
    • readContinueTimeout

      public BUILDER readContinueTimeout(Duration readContinueTimeout)
      Socket 100-Continue read timeout. Default is 1 second. This read timeout is used when 100-Continue is sent by the client, before it sends an entity.
      Parameters:
      readContinueTimeout - read 100-Continue timeout duration
      Returns:
      updated builder instance
      See Also:
    • shareConnectionCache

      public BUILDER shareConnectionCache(boolean shareConnectionCache)
      Whether to share connection cache between all the WebClient instances in JVM.
      Parameters:
      shareConnectionCache - true if connection cache is shared
      Returns:
      updated builder instance
      See Also:
    • maxInMemoryEntity

      public BUILDER maxInMemoryEntity(int maxInMemoryEntity)
      If the entity is expected to be smaller that this number of bytes, it would be buffered in memory to optimize performance. If bigger, streaming will be used.

      Note that for some entity types we cannot use streaming, as they are already fully in memory (String, byte[]), for such cases, this option is ignored. Default is 128Kb.

      Parameters:
      maxInMemoryEntity - maximal number of bytes to buffer in memory for supported writers
      Returns:
      updated builder instance
      See Also:
    • baseUri

      public Optional<ClientUri> baseUri()
      Base uri used by the client in all requests.
      Returns:
      the base uri
    • baseQuery

      public Optional<UriQuery> baseQuery()
      Base query used by the client in all requests.
      Returns:
      the base query
    • baseFragment

      public Optional<UriFragment> baseFragment()
      Base fragment used by the client in all requests (unless overwritten on per-request basis).
      Returns:
      the base fragment
    • socketOptions

      public Optional<SocketOptions> socketOptions()
      Socket options for connections opened by this client. If there is a value explicitly configured on this type and on the socket options, the one configured on this type's builder will win:
      Returns:
      the socket options
    • dnsResolver

      public Optional<DnsResolver> dnsResolver()
      DNS resolver to be used by this client.
      Returns:
      the dns resolver
    • dnsAddressLookup

      public Optional<DnsAddressLookup> dnsAddressLookup()
      DNS address lookup preferences to be used by this client. Default value is determined by capabilities of the system.
      Returns:
      the dns address lookup
    • defaultHeadersMap

      public Map<String,String> defaultHeadersMap()
      Default headers to be used in every request from configuration.
      Returns:
      the default headers map
    • headers

      public Set<Header> headers()
      Default headers to be used in every request.
      Returns:
      the headers
    • mediaTypeParserMode

      public ParserMode mediaTypeParserMode()
      Configure media type parsing mode for HTTP Content-Type header.
      Returns:
      the media type parser mode
    • contentEncoding

      public Optional<ContentEncodingContext> contentEncoding()
      Configure the listener specific ContentEncodingContext. This method discards all previously registered ContentEncodingContext. If no content encoding context is registered, default encoding context is used.
      Returns:
      the content encoding
    • mediaContext

      public MediaContext mediaContext()
      Configure the listener specific MediaContext. This method discards all previously registered MediaContext. If no media context is registered, default media context is used.
      Returns:
      the media context
    • mediaSupports

      public List<MediaSupport> mediaSupports()
      Media supports (manually added). If both mediaContext() and this is configured, there will be a new context created from return of this method, with fallback of mediaContext().
      Returns:
      the media supports
    • services

      public List<WebClientService> services()
      WebClient services.
      Returns:
      the services
    • relativeUris

      public boolean relativeUris()
      Can be set to true to force the use of relative URIs in all requests, regardless of the presence or absence of proxies or no-proxy lists.
      Returns:
      the relative uris
    • executor

      public Optional<ExecutorService> executor()
      Client executor service.
      Returns:
      the executor
    • sendExpectContinue

      public boolean sendExpectContinue()
      Whether Expect-100-Continue header is sent to verify server availability before sending an entity.

      Defaults to true.

      Returns:
      the send expect continue
    • connectionCacheSize

      public int connectionCacheSize()
      Maximal size of the connection cache. For most HTTP protocols, we may cache connections to various endpoints for keep alive (or stream reuse in case of HTTP/2). This option limits the size. Setting this number lower than the "usual" number of target services will cause connections to be closed and reopened frequently.
      Returns:
      the connection cache size
    • cookieManager

      public Optional<WebClientCookieManager> cookieManager()
      WebClient cookie manager.
      Returns:
      the cookie manager
    • readContinueTimeout

      public Duration readContinueTimeout()
      Socket 100-Continue read timeout. Default is 1 second. This read timeout is used when 100-Continue is sent by the client, before it sends an entity.
      Returns:
      the read continue timeout
    • shareConnectionCache

      public boolean shareConnectionCache()
      Whether to share connection cache between all the WebClient instances in JVM.
      Returns:
      the share connection cache
    • maxInMemoryEntity

      public int maxInMemoryEntity()
      If the entity is expected to be smaller that this number of bytes, it would be buffered in memory to optimize performance. If bigger, streaming will be used.

      Note that for some entity types we cannot use streaming, as they are already fully in memory (String, byte[]), for such cases, this option is ignored. Default is 128Kb.

      Returns:
      the max in memory entity
    • config

      public Optional<Config> config()
      If this instance was configured, this would be the config instance used.
      Overrides:
      config in class HttpConfigBase.BuilderBase<BUILDER extends HttpClientConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends HttpClientConfig>
      Returns:
      config node used to configure this builder, or empty if not configured
    • toString

      public String toString()
      Overrides:
      toString in class HttpConfigBase.BuilderBase<BUILDER extends HttpClientConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends HttpClientConfig>
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
      Overrides:
      preBuildPrototype in class HttpConfigBase.BuilderBase<BUILDER extends HttpClientConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends HttpClientConfig>
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.
      Overrides:
      validatePrototype in class HttpConfigBase.BuilderBase<BUILDER extends HttpClientConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends HttpClientConfig>