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;QAC5B,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAErC,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YACpB,SAAS,CAAC,IAAI,GAAG,YAAY,CAAC;QAC/B,CAAC;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAE/C,KAAK,CAAC,OAAO,GAAG,GAAG,GAAG,cAAc,CAAC,MAAM,GAAG,GAAG,GAAG,YAAY,GAAG,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC;QACxF,MAAM,KAAK,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,WAAW,CAAC,MAAM,GAAG,IAAI,UAAU,CAAS,CAAC,QAAQ,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE5F,MAAM,CAAC,WAAW,CAAC;AACpB,CAAC","sourcesContent":["import { Handle } from '../../interfaces';\nimport Set from '@dojo/shim/Set';\nimport WeakMap from '@dojo/shim/WeakMap';\nimport * as http from 'http';\nimport * as https from 'https';\nimport * as urlUtil from 'url';\nimport * as zlib from 'zlib';\nimport Task from '../../async/Task';\nimport { deepAssign } from '../../lang';\nimport { queueTask } from '../../queue';\nimport { createTimer } from '../../util';\nimport Headers from '../Headers';\nimport { RequestOptions, UploadObservableTask } from '../interfaces';\nimport Response from '../Response';\nimport TimeoutError from '../TimeoutError';\nimport { Readable } from 'stream';\nimport Observable from '../../Observable';\nimport SubscriptionPool from '../SubscriptionPool';\n\n/**\n * Request options specific to a node request. For HTTPS options, see\n * https://nodejs.org/api/tls.html#tls_tls_connect_options_callback for more details.\n */\nexport interface NodeRequestOptions extends RequestOptions {\n\t/**\n\t * User-agent header\n\t */\n\tagent?: any;\n\t/**\n\t * If specified, the request body is read from the stream specified here, rather than from the `body` field.\n\t */\n\tbodyStream?: Readable;\n\t/**\n\t * HTTPS optionally override the trusted CA certificates\n\t */\n\tca?: any;\n\t/**\n\t * HTTPS optional cert chains in PEM format. One cert chain should be provided per private key.\n\t */\n\tcert?: string;\n\t/**\n\t * HTTPS optional cipher suite specification\n\t */\n\tciphers?: string;\n\tdataEncoding?: string;\n\t/**\n\t * Whether or not to automatically follow redirects (default true)\n\t */\n\tfollowRedirects?: boolean;\n\t/**\n\t * HTTPS optional private key in PEM format.\n\t */\n\tkey?: string;\n\t/**\n\t * Local interface to bind for network connections.\n\t */\n\tlocalAddress?: string;\n\t/**\n\t * HTTPS optional shared passphrase used for a single private key and/or a PFX.\n\t */\n\tpassphrase?: string;\n\t/**\n\t * HTTPS optional PFX or PKCS12 encoded private key and certificate chain.\n\t */\n\tpfx?: any;\n\t/**\n\t * Optional proxy address. If specified, requests will be sent through this url.\n\t */\n\tproxy?: string;\n\t/**\n\t * HTTPS If not false the server will reject any connection which is not authorized with the list of supplied CAs\n\t */\n\trejectUnauthorized?: boolean;\n\t/**\n\t * HTTPS optional SSL method to use, default is \"SSLv23_method\"\n\t */\n\tsecureProtocol?: string;\n\t/**\n\t * Unix Domain Socket (use one of host:port or socketPath)\n\t */\n\tsocketPath?: string;\n\t/**\n\t * Whether or not to add the gzip and deflate accept headers (default true)\n\t */\n\tacceptCompression?: boolean;\n\t/**\n\t * A set of options to set on the HTTP request\n\t */\n\tsocketOptions?: {\n\t\t/**\n\t\t * Enable/disable keep-alive functionality, and optionally set the initial delay before the first keepalive probe is sent on an idle socket.\n\t\t */\n\t\tkeepAlive?: number;\n\t\t/**\n\t\t * Disables the Nagle algorithm. By default TCP connections use the Nagle algorithm, they buffer data before sending it off.\n\t\t */\n\t\tnoDelay?: boolean;\n\t\t/**\n\t\t * Number of milliseconds before the HTTP request times out\n\t\t */\n\t\ttimeout?: number;\n\t};\n\t/**\n\t * Stream encoding on incoming HTTP response\n\t */\n\tstreamEncoding?: string;\n\t/**\n\t * Options to control redirect follow logic\n\t */\n\tredirectOptions?: {\n\t\t/**\n\t\t * The limit to the number of redirects that will be followed (default 15). This is used to prevent infinite\n\t\t * redirect loops.\n\t\t */\n\t\tlimit?: number;\n\t\tcount?: number;\n\t\t/**\n\t\t * Whether or not to keep the original HTTP method during 301 redirects (default false).\n\t\t */\n\t\tkeepOriginalMethod?: boolean;\n\t};\n}\n\n// TODO: This should be read from the package and not hard coded!\nlet version = '2.0.0-pre';\n\n/**\n * If not overridden, redirects will only be processed this many times before aborting (per request).\n * @type {number}\n */\nconst DEFAULT_REDIRECT_LIMIT = 15;\n\n/**\n * Options to be passed to node's request\n */\ninterface Options {\n\tagent?: any;\n\tauth?: string;\n\theaders?: { [name: string]: string };\n\thost?: string;\n\thostname?: string;\n\tlocalAddress?: string;\n\tmethod?: string;\n\tpath?: string;\n\tport?: number;\n\tsocketPath?: string;\n}\n\n/**\n * HTTPS specific options for node\n */\ninterface HttpsOptions extends Options {\n\tca?: any;\n\tcert?: string;\n\tciphers?: string;\n\tkey?: string;\n\tpassphrase?: string;\n\tpfx?: any;\n\trejectUnauthorized?: boolean;\n\tsecureProtocol?: string;\n}\n\ninterface RequestData {\n\ttask: Task<http.IncomingMessage>;\n\tbuffer: any[];\n\tdata: Buffer;\n\tsize: number;\n\tused: boolean;\n\tnativeResponse: http.IncomingMessage;\n\trequestOptions: NodeRequestOptions;\n\turl: string;\n\tdownloadObservable: Observable<number>;\n\tdataObservable: Observable<any>;\n}\n\nconst dataMap = new WeakMap<NodeResponse, RequestData>();\nconst discardedDuplicates = new Set<string>([\n\t'age',\n\t'authorization',\n\t'content-length',\n\t'content-type',\n\t'etag',\n\t'expires',\n\t'from',\n\t'host',\n\t'if-modified-since',\n\t'if-unmodified-since',\n\t'last-modified',\n\t'location',\n\t'max-forwards',\n\t'proxy-authorization',\n\t'referer',\n\t'retry-after',\n\t'user-agent'\n]);\n\nfunction getDataTask(response: NodeResponse): Task<RequestData> {\n\tconst data = dataMap.get(response)!;\n\n\tif (data.used) {\n\t\treturn Task.reject<any>(new TypeError('Body already read'));\n\t}\n\n\tdata.used = true;\n\n\treturn <Task<RequestData>>data.task.then((_) => data);\n}\n\n/**\n * Turn a node native response object into something that resembles the fetch api\n */\nexport class NodeResponse extends Response {\n\treadonly headers: Headers;\n\treadonly ok: boolean;\n\treadonly status: number;\n\treadonly statusText: string;\n\n\tdownloadBody = true;\n\n\tget bodyUsed(): boolean {\n\t\treturn dataMap.get(this)!.used;\n\t}\n\n\tget nativeResponse(): http.IncomingMessage {\n\t\treturn dataMap.get(this)!.nativeResponse;\n\t}\n\n\tget requestOptions(): NodeRequestOptions {\n\t\treturn dataMap.get(this)!.requestOptions;\n\t}\n\n\tget url(): string {\n\t\treturn dataMap.get(this)!.url;\n\t}\n\n\tget download(): Observable<number> {\n\t\treturn dataMap.get(this)!.downloadObservable;\n\t}\n\n\tget data(): Observable<any> {\n\t\treturn dataMap.get(this)!.dataObservable;\n\t}\n\n\tconstructor(response: http.IncomingMessage) {\n\t\tsuper();\n\n\t\tconst headers = (this.headers = new Headers());\n\t\tfor (let key in response.headers) {\n\t\t\tconst value = response.headers[key];\n\t\t\tif (value) {\n\t\t\t\tif (discardedDuplicates.has(key) && !Array.isArray(value)) {\n\t\t\t\t\theaders.append(key, value);\n\t\t\t\t}\n\t\t\t\t(Array.isArray(value) ? value : value.split(/\\s*,\\s*/)).forEach((v) => {\n\t\t\t\t\theaders.append(key, v);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tthis.status = response.statusCode || 0;\n\t\tthis.ok = this.status >= 200 && this.status < 300;\n\t\tthis.statusText = response.statusMessage || '';\n\t}\n\n\tarrayBuffer(): Task<ArrayBuffer> {\n\t\treturn <any>getDataTask(this).then((data) => {\n\t\t\tif (data) {\n\t\t\t\treturn data.data;\n\t\t\t}\n\n\t\t\treturn new Buffer([]);\n\t\t});\n\t}\n\n\tblob(): Task<Blob> {\n\t\t// Node doesn't support Blobs\n\t\treturn Task.reject<Blob>(new Error('Blob not supported'));\n\t}\n\n\tformData(): Task<FormData> {\n\t\treturn Task.reject<FormData>(new Error('FormData not supported'));\n\t}\n\n\ttext(): Task<string> {\n\t\treturn <any>getDataTask(this).then((data) => {\n\t\t\treturn String(data ? data.data : '');\n\t\t});\n\t}\n}\n\nfunction redirect(\n\tresolve: (p?: any) => void,\n\treject: (_?: Error) => void,\n\toriginalUrl: string,\n\tredirectUrl: string | null,\n\toptions: NodeRequestOptions\n): boolean {\n\tif (!options.redirectOptions) {\n\t\toptions.redirectOptions = {};\n\t}\n\n\tconst { limit: redirectLimit = DEFAULT_REDIRECT_LIMIT, count: redirectCount = 0 } = options.redirectOptions;\n\tconst { followRedirects = true } = options;\n\n\tif (!followRedirects) {\n\t\treturn false;\n\t}\n\n\t// we only check for undefined here because empty string redirects are now allowed\n\t// (they'll resolve to the current url)\n\tif (redirectUrl === undefined || redirectUrl === null) {\n\t\treject(new Error('asked to redirect but no location header was found'));\n\t\treturn true;\n\t}\n\n\tif (redirectCount > redirectLimit) {\n\t\treject(new Error(`too many redirects, limit reached at ${redirectLimit}`));\n\t\treturn true;\n\t}\n\n\toptions.redirectOptions.count = redirectCount + 1;\n\n\t// we wrap the url in a call to node's URL.resolve which will handle relative and partial\n\t// redirects (like \"/another-page\" on the same domain).\n\tresolve(node(urlUtil.resolve(originalUrl, redirectUrl), options));\n\n\treturn true;\n}\n\nexport function getAuth(proxyAuth: string | undefined, options: NodeRequestOptions): string | undefined {\n\tif (proxyAuth) {\n\t\treturn proxyAuth;\n\t}\n\n\tif (options.user || options.password) {\n\t\treturn `${options.user || ''}:${options.password || ''}`;\n\t}\n\n\treturn undefined;\n}\n\nexport default function node(url: string, options: NodeRequestOptions = {}): UploadObservableTask<NodeResponse> {\n\tconst parsedUrl = urlUtil.parse(options.proxy || url);\n\n\tconst requestOptions: HttpsOptions = {\n\t\tagent: options.agent,\n\t\tauth: getAuth(parsedUrl.auth, options),\n\t\tca: options.ca,\n\t\tcert: options.cert,\n\t\tciphers: options.ciphers,\n\t\thost: parsedUrl.host,\n\t\thostname: parsedUrl.hostname,\n\t\tkey: options.key,\n\t\tlocalAddress: options.localAddress,\n\t\tmethod: options.method ? options.method.toUpperCase() : 'GET',\n\t\tpassphrase: options.passphrase,\n\t\tpath: parsedUrl.path,\n\t\tpfx: options.pfx,\n\t\tport: Number(parsedUrl.port),\n\t\trejectUnauthorized: options.rejectUnauthorized,\n\t\tsecureProtocol: options.secureProtocol,\n\t\tsocketPath: options.socketPath\n\t};\n\n\trequestOptions.headers = <{ [key: string]: string }>options.headers || {};\n\n\tif (\n\t\t!Object.keys(requestOptions.headers)\n\t\t\t.map((headerName) => headerName.toLowerCase())\n\t\t\t.some((headerName) => headerName === 'user-agent')\n\t) {\n\t\trequestOptions.headers['user-agent'] = 'dojo/' + version + ' Node.js/' + process.version.replace(/^v/, '');\n\t}\n\n\tif (options.proxy) {\n\t\trequestOptions.path = url;\n\t\tif (parsedUrl.auth) {\n\t\t\trequestOptions.headers['proxy-authorization'] = 'Basic ' + new Buffer(parsedUrl.auth).toString('base64');\n\t\t}\n\n\t\tconst parsedProxyUrl = urlUtil.parse(url);\n\t\tif (parsedProxyUrl.host) {\n\t\t\trequestOptions.headers['host'] = parsedProxyUrl.host;\n\t\t}\n\n\t\tif (parsedProxyUrl.auth) {\n\t\t\trequestOptions.auth = parsedProxyUrl.auth;\n\t\t}\n\t}\n\n\tconst { acceptCompression = true } = options;\n\tif (acceptCompression) {\n\t\trequestOptions.headers['Accept-Encoding'] = 'gzip, deflate';\n\t}\n\n\tconst request = parsedUrl.protocol === 'https:' ? https.request(requestOptions) : http.request(requestOptions);\n\n\tconst uploadObserverPool = new SubscriptionPool<number>();\n\n\tconst requestTask = <UploadObservableTask<NodeResponse>>new Task<NodeResponse>(\n\t\t(resolve, reject) => {\n\t\t\tlet timeoutHandle: Handle;\n\t\t\tlet timeoutReject: Function = reject;\n\n\t\t\tif (options.socketOptions) {\n\t\t\t\tif (options.socketOptions.timeout) {\n\t\t\t\t\trequest.setTimeout(options.socketOptions.timeout);\n\t\t\t\t}\n\n\t\t\t\tif ('noDelay' in options.socketOptions) {\n\t\t\t\t\trequest.setNoDelay(options.socketOptions.noDelay);\n\t\t\t\t}\n\n\t\t\t\tif ('keepAlive' in options.socketOptions) {\n\t\t\t\t\tconst initialDelay: number | undefined = options.socketOptions.keepAlive;\n\t\t\t\t\tif (initialDelay !== undefined) {\n\t\t\t\t\t\trequest.setSocketKeepAlive(initialDelay >= 0, initialDelay);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trequest.once('response', (message: http.IncomingMessage) => {\n\t\t\t\tconst response = new NodeResponse(message);\n\n\t\t\t\t// Redirection handling defaults to true in order to harmonise with the XHR provider, which will always\n\t\t\t\t// follow redirects\n\t\t\t\tif (response.status >= 300 && response.status < 400) {\n\t\t\t\t\tconst redirectOptions = options.redirectOptions || {};\n\t\t\t\t\tconst newOptions = deepAssign({}, options);\n\n\t\t\t\t\tswitch (response.status) {\n\t\t\t\t\t\tcase 300:\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * Note about 300 redirects. RFC 2616 doesn't specify what to do with them, it is up to the client to \"pick\n\t\t\t\t\t\t\t * the right one\".  We're picking like Chrome does, just don't pick any.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 301:\n\t\t\t\t\t\tcase 302:\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * RFC 2616 says,\n\t\t\t\t\t\t\t *\n\t\t\t\t\t\t\t *     If the 301 status code is received in response to a request other\n\t\t\t\t\t\t\t *     than GET or HEAD, the user agent MUST NOT automatically redirect the\n\t\t\t\t\t\t\t *     request unless it can be confirmed by the user, since this might\n\t\t\t\t\t\t\t *       change the conditions under which the request was issued.\n\t\t\t\t\t\t\t *\n\t\t\t\t\t\t\t *     Note: When automatically redirecting a POST request after\n\t\t\t\t\t\t\t *     receiving a 301 status code, some existing HTTP/1.0 user agents\n\t\t\t\t\t\t\t *     will erroneously change it into a GET request.\n\t\t\t\t\t\t\t *\n\t\t\t\t\t\t\t * We're going to be one of those erroneous agents, to prevent the request from failing..\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequestOptions.method !== 'GET' &&\n\t\t\t\t\t\t\t\trequestOptions.method !== 'HEAD' &&\n\t\t\t\t\t\t\t\t!redirectOptions.keepOriginalMethod\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnewOptions.method = 'GET';\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (redirect(resolve, reject, url, response.headers.get('location'), newOptions)) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 303:\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * The response to the request can be found under a different URI and\n\t\t\t\t\t\t\t * SHOULD be retrieved using a GET method on that resource.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (requestOptions.method !== 'GET') {\n\t\t\t\t\t\t\t\tnewOptions.method = 'GET';\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (redirect(resolve, reject, url, response.headers.get('location'), newOptions)) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 304:\n\t\t\t\t\t\t\t// do nothing so this can fall through and return the response as normal. Nothing more can\n\t\t\t\t\t\t\t// be done for 304\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 305:\n\t\t\t\t\t\t\tif (!response.headers.get('location')) {\n\t\t\t\t\t\t\t\treject(new Error('expected Location header to contain a proxy url'));\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tnewOptions.proxy = response.headers.get('location') || '';\n\t\t\t\t\t\t\t\tif (redirect(resolve, reject, url, '', newOptions)) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 307:\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t *  If the 307 status code is received in response to a request other\n\t\t\t\t\t\t\t *  than GET or HEAD, the user agent MUST NOT automatically redirect the\n\t\t\t\t\t\t\t *  request unless it can be confirmed by the user, since this might\n\t\t\t\t\t\t\t *  change the conditions under which the request was issued.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (redirect(resolve, reject, url, response.headers.get('location'), newOptions)) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treject(new Error('unhandled redirect status ' + response.status));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\toptions.streamEncoding && message.setEncoding(options.streamEncoding);\n\n\t\t\t\tconst downloadSubscriptionPool = new SubscriptionPool<number>();\n\t\t\t\tconst dataSubscriptionPool = new SubscriptionPool<any>();\n\n\t\t\t\t/*\n\t\t\t [RFC 2616](https://tools.ietf.org/html/rfc2616#page-118) says that content-encoding can have multiple\n\t\t\t values, so we split them here and put them in a list to process later.\n\t\t\t */\n\t\t\t\tconst contentEncodings = response.headers.getAll('content-encoding');\n\n\t\t\t\tconst task = new Task<http.IncomingMessage>(\n\t\t\t\t\t(resolve, reject) => {\n\t\t\t\t\t\ttimeoutReject = reject;\n\n\t\t\t\t\t\t// we queue this up for later to allow listeners to register themselves before we start receiving data\n\t\t\t\t\t\tqueueTask(() => {\n\t\t\t\t\t\t\t/*\n\t\t\t\t\t * Note that this is the raw data, if your input stream is zipped, and you are piecing\n\t\t\t\t\t * together the downloaded data, you'll have to decompress it yourself\n\t\t\t\t\t */\n\t\t\t\t\t\t\tmessage.on('data', (chunk: any) => {\n\t\t\t\t\t\t\t\tdataSubscriptionPool.next(chunk);\n\n\t\t\t\t\t\t\t\tif (response.downloadBody) {\n\t\t\t\t\t\t\t\t\tdata.buffer.push(chunk);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tdata.size +=\n\t\t\t\t\t\t\t\t\ttypeof chunk === 'string'\n\t\t\t\t\t\t\t\t\t\t? Buffer.byteLength(chunk, options.streamEncoding)\n\t\t\t\t\t\t\t\t\t\t: chunk.length;\n\n\t\t\t\t\t\t\t\tdownloadSubscriptionPool.next(data.size);\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tmessage.once('end', () => {\n\t\t\t\t\t\t\t\ttimeoutHandle && timeoutHandle.destroy();\n\n\t\t\t\t\t\t\t\tlet dataAsBuffer = options.streamEncoding\n\t\t\t\t\t\t\t\t\t? new Buffer(data.buffer.join(''), 'utf8')\n\t\t\t\t\t\t\t\t\t: Buffer.concat(data.buffer, data.size);\n\n\t\t\t\t\t\t\t\tconst handleEncoding = function() {\n\t\t\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t Content encoding is ordered by the order in which they were applied to the\n\t\t\t\t\t\t\t content, so do undo the encoding we have to start at the end and work backwards.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\t\tif (contentEncodings.length) {\n\t\t\t\t\t\t\t\t\t\tconst encoding = contentEncodings.pop()!.trim().toLowerCase();\n\n\t\t\t\t\t\t\t\t\t\tif (encoding === '' || encoding === 'none' || encoding === 'identity') {\n\t\t\t\t\t\t\t\t\t\t\t// do nothing, response stream is as-is\n\t\t\t\t\t\t\t\t\t\t\thandleEncoding();\n\t\t\t\t\t\t\t\t\t\t} else if (encoding === 'gzip') {\n\t\t\t\t\t\t\t\t\t\t\tzlib.gunzip(dataAsBuffer, function(err: Error | null, result: Buffer) {\n\t\t\t\t\t\t\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tdataAsBuffer = result;\n\t\t\t\t\t\t\t\t\t\t\t\thandleEncoding();\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t} else if (encoding === 'deflate') {\n\t\t\t\t\t\t\t\t\t\t\tzlib.inflate(dataAsBuffer, function(err: Error | null, result: Buffer) {\n\t\t\t\t\t\t\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tdataAsBuffer = result;\n\t\t\t\t\t\t\t\t\t\t\t\thandleEncoding();\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\treject(new Error('Unsupported content encoding, ' + encoding));\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tdata.data = dataAsBuffer;\n\n\t\t\t\t\t\t\t\t\t\tresolve(message);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\thandleEncoding();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\trequest.abort();\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst data: RequestData = {\n\t\t\t\t\ttask,\n\t\t\t\t\tbuffer: [],\n\t\t\t\t\tdata: Buffer.alloc(0),\n\t\t\t\t\tsize: 0,\n\t\t\t\t\tused: false,\n\t\t\t\t\turl: url,\n\t\t\t\t\trequestOptions: options,\n\t\t\t\t\tnativeResponse: message,\n\t\t\t\t\tdownloadObservable: new Observable<number>((observer) => downloadSubscriptionPool.add(observer)),\n\t\t\t\t\tdataObservable: new Observable<any>((observer) => dataSubscriptionPool.add(observer))\n\t\t\t\t};\n\n\t\t\t\tdataMap.set(response, data);\n\n\t\t\t\tresolve(response);\n\t\t\t});\n\n\t\t\trequest.once('error', reject);\n\n\t\t\tif (options.bodyStream) {\n\t\t\t\toptions.bodyStream.pipe(request);\n\t\t\t\tlet uploadedSize = 0;\n\n\t\t\t\toptions.bodyStream.on('data', (chunk: any) => {\n\t\t\t\t\tuploadedSize += chunk.length;\n\t\t\t\t\tuploadObserverPool.next(uploadedSize);\n\t\t\t\t});\n\n\t\t\t\toptions.bodyStream.on('end', () => {\n\t\t\t\t\tuploadObserverPool.complete();\n\t\t\t\t\trequest.end();\n\t\t\t\t});\n\t\t\t} else if (options.body) {\n\t\t\t\tconst body = options.body.toString();\n\n\t\t\t\trequest.on('response', () => {\n\t\t\t\t\tuploadObserverPool.next(body.length);\n\t\t\t\t});\n\n\t\t\t\trequest.end(body);\n\t\t\t} else {\n\t\t\t\trequest.end();\n\t\t\t}\n\n\t\t\tif (options.timeout && options.timeout > 0 && options.timeout !== Infinity) {\n\t\t\t\ttimeoutHandle = createTimer(() => {\n\t\t\t\t\ttimeoutReject && timeoutReject(new TimeoutError('The request timed out'));\n\t\t\t\t}, options.timeout);\n\t\t\t}\n\t\t},\n\t\t() => {\n\t\t\trequest.abort();\n\t\t}\n\t).catch(function(error: Error): any {\n\t\tconst parsedUrl = urlUtil.parse(url);\n\n\t\tif (parsedUrl.auth) {\n\t\t\tparsedUrl.auth = '(redacted)';\n\t\t}\n\n\t\tconst sanitizedUrl = urlUtil.format(parsedUrl);\n\n\t\terror.message = '[' + requestOptions.method + ' ' + sanitizedUrl + '] ' + error.message;\n\t\tthrow error;\n\t});\n\n\trequestTask.upload = new Observable<number>((observer) => uploadObserverPool.add(observer));\n\n\treturn requestTask;\n}\n"]}