typed-rest-client
Version:
Node Rest and Http Clients for use with TypeScript
37 lines (36 loc) • 1.49 kB
TypeScript
import { IRequestQueryParams, IHttpClientResponse } from './Interfaces';
/**
* creates an url from a request url and optional base url (http://server:8080)
* @param {string} resource - a fully qualified url or relative path
* @param {string} baseUrl - an optional baseUrl (http://server:8080)
* @param {IRequestOptions} options - an optional options object, could include QueryParameters e.g.
* @return {string} - resultant url
*/
export declare function getUrl(resource: string, baseUrl?: string, queryParams?: IRequestQueryParams): string;
/**
* Decompress/Decode gzip encoded JSON
* Using Node.js built-in zlib module
*
* @param {Buffer} buffer
* @param {string} charset? - optional; defaults to 'utf-8'
* @return {Promise<string>}
*/
export declare function decompressGzippedContent(buffer: Buffer, charset?: BufferEncoding): Promise<string>;
/**
* Builds a RegExp to test urls against for deciding
* wether to bypass proxy from an entry of the
* environment variable setting NO_PROXY
*
* @param {string} bypass
* @return {RegExp}
*/
export declare function buildProxyBypassRegexFromEnv(bypass: string): RegExp;
/**
* Obtain Response's Content Charset.
* Through inspecting `content-type` response header.
* It Returns 'utf-8' if NO charset specified/matched.
*
* @param {IHttpClientResponse} response
* @return {string} - Content Encoding Charset; Default=utf-8
*/
export declare function obtainContentCharset(response: IHttpClientResponse): BufferEncoding;