withBasePath method

HttpClient withBasePath(
  1. String basePath
)

Returns a new HttpClient instance using basePath as path of baseURL.

Implementation

HttpClient withBasePath(String basePath) {
  var uri = Uri.parse(baseURL);

  var uri2 = Uri(
    scheme: uri.scheme,
    host: uri.host,
    port: (uri.port != 80 && uri.port != 443) ? uri.port : null,
    path: basePath,
    query: uri.hasQuery ? uri.query : null,
    userInfo: isNotEmptyString(uri.userInfo) ? uri.userInfo : null,
  );

  return withBaseURL(uri2.toString());
}