From 315473ce353b9a42c5165fa9c507ed5ded86fa73 Mon Sep 17 00:00:00 2001 From: Anandhu Dhanapal Date: Tue, 23 May 2023 15:10:15 +0530 Subject: [PATCH 1/5] Fix: Updating the way how we invoke the request from urllib --- lib/http/base.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/http/base.js b/lib/http/base.js index 00ad17234..47383c788 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,19 +50,19 @@ HttpClient.prototype.request = function (options) var headers; var json; var body; - var request; + var httpRequest; // normalize the headers headers = normalizeHeaders(options.headers); - // create a function to send the request + // create a function to send the httpRequest var sendRequest = async function sendRequest() { var url = options.url; Logger.getInstance().trace(url); - // build the basic request options + // build the basic httpRequest options var requestOptions = { method: options.method, @@ -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 @@ -115,8 +116,8 @@ HttpClient.prototype.request = function (options) }; sendRequest = sendRequest.bind(this); - // if a request body is specified and compression is enabled, - // try to compress the request body before sending the request + // if a httpRequest body is specified and compression is enabled, + // try to compress the httpRequest body before sending the httpRequest json = body = options.json; if (body) { @@ -135,7 +136,7 @@ HttpClient.prototype.request = function (options) } else { - Logger.getInstance().warn('Could not compress request body.'); + Logger.getInstance().warn('Could not compress httpRequest body.'); } sendRequest(); @@ -151,14 +152,14 @@ HttpClient.prototype.request = function (options) process.nextTick(sendRequest); } - // return an externalized request object that only contains + // return an externalized httpRequest object that only contains // methods we're comfortable exposing to the outside world 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 +} From 21f8459a11c276535968f116ce619b59ca689fe8 Mon Sep 17 00:00:00 2001 From: Anandhu Dhanapal Date: Tue, 23 May 2023 15:13:07 +0530 Subject: [PATCH 2/5] Update base.js --- lib/http/base.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/http/base.js b/lib/http/base.js index 47383c788..9ef15a5de 100644 --- a/lib/http/base.js +++ b/lib/http/base.js @@ -55,14 +55,14 @@ HttpClient.prototype.request = function (options) // normalize the headers headers = normalizeHeaders(options.headers); - // create a function to send the httpRequest + // create a function to send the request var sendRequest = async function sendRequest() { var url = options.url; Logger.getInstance().trace(url); - // build the basic httpRequest options + // build the basic request options var requestOptions = { method: options.method, @@ -116,8 +116,8 @@ HttpClient.prototype.request = function (options) }; sendRequest = sendRequest.bind(this); - // if a httpRequest body is specified and compression is enabled, - // try to compress the httpRequest body before sending the httpRequest + // if a request body is specified and compression is enabled, + // try to compress the httpRequest body before sending the request json = body = options.json; if (body) { @@ -136,7 +136,7 @@ HttpClient.prototype.request = function (options) } else { - Logger.getInstance().warn('Could not compress httpRequest body.'); + Logger.getInstance().warn('Could not compress request body.'); } sendRequest(); @@ -152,7 +152,7 @@ HttpClient.prototype.request = function (options) process.nextTick(sendRequest); } - // return an externalized httpRequest object that only contains + // return an externalized request object that only contains // methods we're comfortable exposing to the outside world return { abort: function () From 3d319c9978a5bb7551c8d801f86c3bae9903bb7c Mon Sep 17 00:00:00 2001 From: Anandhu Dhanapal Date: Tue, 23 May 2023 15:13:35 +0530 Subject: [PATCH 3/5] Update base.js --- lib/http/base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/http/base.js b/lib/http/base.js index 9ef15a5de..252cd344d 100644 --- a/lib/http/base.js +++ b/lib/http/base.js @@ -117,7 +117,7 @@ HttpClient.prototype.request = function (options) sendRequest = sendRequest.bind(this); // if a request body is specified and compression is enabled, - // try to compress the httpRequest body before sending the request + // try to compress the request body before sending the request json = body = options.json; if (body) { From 1b02bf3f158ed14529550a9cd777596bc0329309 Mon Sep 17 00:00:00 2001 From: Anandhu Dhanapal Date: Tue, 23 May 2023 15:32:49 +0530 Subject: [PATCH 4/5] Update base.js From cb7069579947fb7f33e3a84dfac77062e329a64a Mon Sep 17 00:00:00 2001 From: Anandhu Dhanapal Date: Tue, 23 May 2023 15:33:20 +0530 Subject: [PATCH 5/5] Update base.js