Class WebClient.Builder

    • Method Detail

      • build

        public WebClient build()
        Description copied from interface: Builder
        Build the instance from this builder.
        Specified by:
        build in interface Builder<WebClient>
        Returns:
        instance of the built type
      • 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
      • 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