supra-http
Advanced tools
Comparing version 1.0.4 to 1.0.7
@@ -33,3 +33,3 @@ "use strict"; | ||
const options = this.createRequestOptions(url, requestOptions, requestProvider.agent, requestBody); | ||
return new Promise(resolve => { | ||
return new Promise((resolve, reject) => { | ||
const request = requestProvider.client.request(options, response => { | ||
@@ -42,2 +42,4 @@ compression_1.Compression.handle(response) | ||
}); | ||
request.on('error', reject); | ||
request.on('timeout', request.abort); | ||
if (requestBody) { | ||
@@ -59,2 +61,5 @@ request.write(requestBody); | ||
}; | ||
if (options.timeout) { | ||
mergedOptions.timeout = options.timeout; | ||
} | ||
if (options.json) { | ||
@@ -61,0 +66,0 @@ mergedOptions.headers['content-type'] = enums_1.CONTENT_TYPE.ApplicationJson; |
@@ -9,5 +9,5 @@ /// <reference types="node" /> | ||
headers?: Record<string, string>; | ||
timeout?: number; | ||
} | ||
interface RequestOptions extends CircuitBreaker.Options, HttpRequestOptions { | ||
timeout?: number; | ||
} | ||
@@ -14,0 +14,0 @@ interface ClientResponse { |
{ | ||
"name": "supra-http", | ||
"version": "1.0.4", | ||
"version": "1.0.7", | ||
"description": "Circuit breaking http client for NodeJs. And it is fast...", | ||
@@ -18,2 +18,3 @@ "main": "./dist/index.js", | ||
"build": "node ./node_modules/.bin/tsc", | ||
"bench": "npm run build && node ./benchmark/index.js", | ||
"build:watch": "node ./node_modules/.bin/tsc --watch", | ||
@@ -20,0 +21,0 @@ "test:watch": "jest --coverage --watchAll" |
Sorry, the diff of this file is not supported yet
16653
251