diff --git a/lib/http/base.js b/lib/http/base.js index 00ad17234..252cd344d 100644 --- a/lib/http/base.js +++ b/lib/http/base.js @@ -6,6 +6,7 @@ const zlib = require('zlib'); const Util = require('../util'); const Errors = require('../errors'); const Logger = require('../logger'); +const {request} = require('urllib'); const DEFAULT_REQUEST_TIMEOUT = 360000; @@ -49,7 +50,7 @@ HttpClient.prototype.request = function (options) var headers; var json; var body; - var request; + var httpRequest; // normalize the headers headers = normalizeHeaders(options.headers); @@ -95,7 +96,7 @@ HttpClient.prototype.request = function (options) requestOptions.httpsAgent.keepAlive = agentAndProxyOptions.agentOptions.keepAlive; requestOptions.retryDelay = this.constructExponentialBackoffStrategy(); - request = require('urllib').request(requestOptions.url, requestOptions, async function (err, data, response) + httpRequest = request(requestOptions.url, requestOptions, async function (err, data, response) { // if a callback has been specified, normalize the // response before passing it to the callback @@ -156,9 +157,9 @@ HttpClient.prototype.request = function (options) return { abort: function () { - if (request) + if (httpRequest) { - request.abort(); + httpRequest.abort(); } } }; @@ -262,4 +263,4 @@ function normalizeResponse(response) } return response; -} \ No newline at end of file +}