Class WebClient.Builder

java.lang.Object
io.helidon.webclient.WebClient.Builder
All Implemented Interfaces:
Builder<WebClient.Builder,WebClient>, MediaContextBuilder<WebClient.Builder>, ParentingMediaContextBuilder<WebClient.Builder>, Supplier<WebClient>
Enclosing interface:
WebClient

Fluent API builder for WebClient.
  • Method Details

    • build

      public WebClient build()
      Description copied from interface: Builder
      Build the instance from this builder.
      Specified by:
      build in interface Builder<WebClient.Builder,WebClient>
      Returns:
      instance of the built type
    • addService

      public WebClient.Builder addService(WebClientService service)
      Register new instance of WebClientService.
      Parameters:
      service - client service instance
      Returns:
      updated builder instance
    • addService

      public WebClient.Builder addService(Supplier<? extends WebClientService> serviceSupplier)
      Register new instance of WebClientService.
      Parameters:
      serviceSupplier - client service instance
      Returns:
      updated builder instance
    • useSystemServiceLoader

      public WebClient.Builder useSystemServiceLoader(boolean useServiceLoader)
      Sets if Java Service loader should be used to load all WebClientServiceProvider.
      Parameters:
      useServiceLoader - whether to use the Java Service loader
      Returns:
      updated builder instance
    • proxy

      public WebClient.Builder proxy(Proxy proxy)
      Sets new proxy which will used for the requests.
      Parameters:
      proxy - proxy instance
      Returns:
      updated builder instance
    • relativeUris

      public WebClient.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
    • mediaContext

      public WebClient.Builder mediaContext(MediaContext mediaContext)
      Description copied from interface: ParentingMediaContextBuilder
      Sets the MediaContext parent and overrides the existing one. This method discards all previously registered readers and writers via builder.
      Specified by:
      mediaContext in interface ParentingMediaContextBuilder<WebClient.Builder>
      Parameters:
      mediaContext - media context
      Returns:
      updated instance of the builder
    • addMediaSupport

      public WebClient.Builder addMediaSupport(MediaSupport mediaSupport)
      Description copied from interface: MediaContextBuilder
      Adds new instance of MediaSupport.
      Specified by:
      addMediaSupport in interface MediaContextBuilder<WebClient.Builder>
      Parameters:
      mediaSupport - media support
      Returns:
      updated instance of the builder
    • addReader

      public WebClient.Builder addReader(MessageBodyReader<?> reader)
      Description copied from interface: MediaContextBuilder
      Registers new reader.
      Specified by:
      addReader in interface MediaContextBuilder<WebClient.Builder>
      Parameters:
      reader - reader
      Returns:
      updated instance of the builder
    • addStreamReader

      public WebClient.Builder addStreamReader(MessageBodyStreamReader<?> streamReader)
      Description copied from interface: MediaContextBuilder
      Registers new stream reader.
      Specified by:
      addStreamReader in interface MediaContextBuilder<WebClient.Builder>
      Parameters:
      streamReader - stream reader
      Returns:
      updated instance of the builder
    • addWriter

      public WebClient.Builder addWriter(MessageBodyWriter<?> writer)
      Description copied from interface: MediaContextBuilder
      Registers new writer.
      Specified by:
      addWriter in interface MediaContextBuilder<WebClient.Builder>
      Parameters:
      writer - writer
      Returns:
      updated instance of the builder
    • addStreamWriter

      public WebClient.Builder addStreamWriter(MessageBodyStreamWriter<?> streamWriter)
      Description copied from interface: MediaContextBuilder
      Registers new stream writer.
      Specified by:
      addStreamWriter in interface MediaContextBuilder<WebClient.Builder>
      Parameters:
      streamWriter - stream writer
      Returns:
      updated instance of the builder
    • config

      public WebClient.Builder config(Config config)
      Config of this client.
      Parameters:
      config - client config
      Returns:
      updated builder instance
    • connectTimeout

      public WebClient.Builder connectTimeout(long amount, TimeUnit unit)
      Sets new connection timeout.
      Parameters:
      amount - amount of time
      unit - time unit
      Returns:
      updated builder instance
    • readTimeout

      public WebClient.Builder readTimeout(long amount, TimeUnit unit)
      Sets new read timeout.
      Parameters:
      amount - amount of time
      unit - time unit
      Returns:
      updated builder instance
    • tls

      public WebClient.Builder tls(WebClientTls webClientTls)
      Sets new WebClientTls instance which contains ssl configuration.
      Parameters:
      webClientTls - tls instance
      Returns:
      updated builder instance
    • context

      public WebClient.Builder context(Context context)
      Sets specific context which should be used in requests.
      Parameters:
      context - context
      Returns:
      updated builder instance
    • addCookie

      public WebClient.Builder addCookie(String name, String value)
      Add a default cookie.
      Parameters:
      name - cookie name
      value - cookie value
      Returns:
      updated builder instance
    • addHeader

      public WebClient.Builder addHeader(String header, String... value)
      Add a default header (such as accept).
      Parameters:
      header - header name
      value - header values
      Returns:
      updated builder instance
    • baseUri

      public WebClient.Builder baseUri(URI uri)
      Sets base uri for each request.
      Parameters:
      uri - base uri
      Returns:
      updated builder instance
    • baseUri

      public WebClient.Builder baseUri(String uri)
      Sets base uri for each request.
      Parameters:
      uri - base uri
      Returns:
      updated builder instance
    • baseUri

      public WebClient.Builder baseUri(URL url)
      Sets base url for each request.
      Parameters:
      url - base url
      Returns:
      updated builder instance
    • followRedirects

      public WebClient.Builder followRedirects(boolean follow)
      Sets if redirects should be followed or not.
      Parameters:
      follow - follow redirects
      Returns:
      updated builder instance
    • userAgent

      public WebClient.Builder userAgent(String userAgent)
      Sets user agent name.
      Parameters:
      userAgent - user agent
      Returns:
      updated builder instance
    • keepAlive

      public WebClient.Builder keepAlive(boolean keepAlive)
      Set whether connection to server should be kept alive after request. This also sets header Http.Header.CONNECTION to keep-alive.
      Parameters:
      keepAlive - keep connection alive
      Returns:
      updated builder instance
    • validateHeaders

      public WebClient.Builder validateHeaders(boolean validate)
      Whether to validate header names. Defaults to true.
      Parameters:
      validate - whether to validate the header name contains only allowed characters
      Returns:
      updated builder instance
    • dnsResolverType

      public WebClient.Builder dnsResolverType(DnsResolverType dnsResolverType)
      Set which type of DNS resolver should be used.
      Parameters:
      dnsResolverType - type of the DNS resolver to be used
      Returns:
      updated builder instance
    • enableAutomaticCookieStore

      public WebClient.Builder enableAutomaticCookieStore(boolean enableAutomaticCookieStore)
      Set whether cookies should be automatically saved to the store.
      Parameters:
      enableAutomaticCookieStore - whether to save cookies, default is false
      Returns:
      updated builder instance
    • mediaTypeParserRelaxed

      public WebClient.Builder mediaTypeParserRelaxed(boolean relaxedMode)
      Configure media type parsing mode for HTTP Content-Type header. Media type parsing in relaxed mode accepts incomplete Content-Type values like "text", which are accepted as corresponding complete value, e.g. "text/plain". Parsing in strict mode (default) expect exact Content-Type matching.
      Parameters:
      relaxedMode - value of true sets relaxed media type parsing mode, value of false sets strict media type parsing mode
      Returns:
      updated builder instance