withBaseURL method

HttpClient withBaseURL(
  1. String baseURL, {
  2. bool preserveAuthorization = false,
})

Returns a new HttpClient instance using baseURL.

preserveAuthorization if true will keep the same authorization instance. NOTE: If the current instance is using the same baseURL, this instance is returned.

Implementation

HttpClient withBaseURL(String baseURL, {bool preserveAuthorization = false}) {
  if (this.baseURL == baseURL) {
    return this;
  }
  var httpClient = HttpClient(baseURL, clientRequester)
    ..userAgent = userAgent;

  if (preserveAuthorization) {
    httpClient._authorization = _authorization;
  }

  return httpClient;
}