@algolia/requester-node-http 5.8.0 → 5.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../index.ts","../src/createHttpRequester.ts"],"sourcesContent":["export * from './src/createHttpRequester';\n","import http from 'http';\nimport https from 'https';\nimport { URL } from 'url';\n\nimport type { EndRequest, Requester, Response } from '@algolia/client-common';\n\nexport type CreateHttpRequesterOptions = Partial<{\n agent: http.Agent | https.Agent;\n httpAgent: http.Agent;\n httpsAgent: https.Agent;\n /**\n * RequestOptions to be merged with the end request, it will override default options if provided.\n */\n requesterOptions: https.RequestOptions;\n}>;\n\n// Global agents allow us to reuse the TCP protocol with multiple clients\nconst agentOptions = { keepAlive: true };\nconst defaultHttpAgent = new http.Agent(agentOptions);\nconst defaultHttpsAgent = new https.Agent(agentOptions);\n\nexport function createHttpRequester({\n agent: userGlobalAgent,\n httpAgent: userHttpAgent,\n httpsAgent: userHttpsAgent,\n requesterOptions = {},\n}: CreateHttpRequesterOptions = {}): Requester {\n const httpAgent = userHttpAgent || userGlobalAgent || defaultHttpAgent;\n const httpsAgent = userHttpsAgent || userGlobalAgent || defaultHttpsAgent;\n\n function send(request: EndRequest): Promise<Response> {\n return new Promise((resolve) => {\n let responseTimeout: NodeJS.Timeout | undefined;\n // eslint-disable-next-line prefer-const -- linter thinks this is not reassigned\n let connectTimeout: NodeJS.Timeout | undefined;\n const url = new URL(request.url);\n const path = url.search === null ? url.pathname : `${url.pathname}${url.search}`;\n const options: https.RequestOptions = {\n agent: url.protocol === 'https:' ? httpsAgent : httpAgent,\n hostname: url.hostname,\n path,\n method: request.method,\n ...requesterOptions,\n headers: {\n ...request.headers,\n ...requesterOptions.headers,\n },\n };\n\n if (url.port && !requesterOptions.port) {\n options.port = url.port;\n }\n\n const req = (url.protocol === 'https:' ? https : http).request(options, (response) => {\n let contentBuffers: Buffer[] = [];\n\n response.on('data', (chunk) => {\n contentBuffers = contentBuffers.concat(chunk);\n });\n\n response.on('end', () => {\n clearTimeout(connectTimeout as NodeJS.Timeout);\n clearTimeout(responseTimeout as NodeJS.Timeout);\n\n resolve({\n status: response.statusCode || 0,\n content: Buffer.concat(contentBuffers).toString(),\n isTimedOut: false,\n });\n });\n });\n\n const createTimeout = (timeout: number, content: string): NodeJS.Timeout => {\n return setTimeout(() => {\n req.destroy();\n\n resolve({\n status: 0,\n content,\n isTimedOut: true,\n });\n }, timeout);\n };\n\n connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');\n\n req.on('error', (error) => {\n clearTimeout(connectTimeout as NodeJS.Timeout);\n clearTimeout(responseTimeout!);\n resolve({ status: 0, content: error.message, isTimedOut: false });\n });\n\n req.once('response', () => {\n clearTimeout(connectTimeout as NodeJS.Timeout);\n responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');\n });\n\n if (request.data !== undefined) {\n req.write(request.data);\n }\n\n req.end();\n });\n }\n\n return { send };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAiB;AACjB,mBAAkB;AAClB,iBAAoB;AAepB,IAAM,eAAe,EAAE,WAAW,KAAK;AACvC,IAAM,mBAAmB,IAAI,YAAAA,QAAK,MAAM,YAAY;AACpD,IAAM,oBAAoB,IAAI,aAAAC,QAAM,MAAM,YAAY;AAE/C,SAAS,oBAAoB;AAAA,EAClC,OAAO;AAAA,EACP,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,mBAAmB,CAAC;AACtB,IAAgC,CAAC,GAAc;AAC7C,QAAM,YAAY,iBAAiB,mBAAmB;AACtD,QAAM,aAAa,kBAAkB,mBAAmB;AAExD,WAAS,KAAK,SAAwC;AACpD,WAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAI;AAEJ,UAAI;AACJ,YAAM,MAAM,IAAI,eAAI,QAAQ,GAAG;AAC/B,YAAM,OAAO,IAAI,WAAW,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I,KAAK,YAAY,MAAM;AACzB,qBAAa,cAAgC;AAC7C,0BAAkB,cAAc,QAAQ,iBAAiB,gBAAgB;AAAA,MAC3E,CAAC;AAED,UAAI,QAAQ,SAAS,QAAW;AAC9B,YAAI,MAAM,QAAQ,IAAI;AAAA,MACxB;AAEA,UAAI,IAAI;AAAA,IACV,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,KAAK;AAChB;","names":["http","https"]}
1
+ {"version":3,"sources":["../index.ts","../src/createHttpRequester.ts"],"sourcesContent":["export * from './src/createHttpRequester';\n","import http from 'http';\nimport https from 'https';\nimport { URL } from 'url';\n\nimport type { EndRequest, Requester, Response } from '@algolia/client-common';\n\nexport type CreateHttpRequesterOptions = Partial<{\n agent: http.Agent | https.Agent;\n httpAgent: http.Agent;\n httpsAgent: https.Agent;\n /**\n * RequestOptions to be merged with the end request, it will override default options if provided.\n */\n requesterOptions: https.RequestOptions;\n}>;\n\n// Global agents allow us to reuse the TCP protocol with multiple clients\nconst agentOptions = { keepAlive: true };\nconst defaultHttpAgent = new http.Agent(agentOptions);\nconst defaultHttpsAgent = new https.Agent(agentOptions);\n\nexport function createHttpRequester({\n agent: userGlobalAgent,\n httpAgent: userHttpAgent,\n httpsAgent: userHttpsAgent,\n requesterOptions = {},\n}: CreateHttpRequesterOptions = {}): Requester {\n const httpAgent = userHttpAgent || userGlobalAgent || defaultHttpAgent;\n const httpsAgent = userHttpsAgent || userGlobalAgent || defaultHttpsAgent;\n\n function send(request: EndRequest): Promise<Response> {\n return new Promise((resolve) => {\n let responseTimeout: NodeJS.Timeout | undefined;\n let connectTimeout: NodeJS.Timeout | undefined;\n const url = new URL(request.url);\n const path = url.search === null ? url.pathname : `${url.pathname}${url.search}`;\n const options: https.RequestOptions = {\n agent: url.protocol === 'https:' ? httpsAgent : httpAgent,\n hostname: url.hostname,\n path,\n method: request.method,\n ...requesterOptions,\n headers: {\n ...request.headers,\n ...requesterOptions.headers,\n },\n };\n\n if (url.port && !requesterOptions.port) {\n options.port = url.port;\n }\n\n const req = (url.protocol === 'https:' ? https : http).request(options, (response) => {\n let contentBuffers: Buffer[] = [];\n\n response.on('data', (chunk) => {\n contentBuffers = contentBuffers.concat(chunk);\n });\n\n response.on('end', () => {\n clearTimeout(connectTimeout as NodeJS.Timeout);\n clearTimeout(responseTimeout as NodeJS.Timeout);\n\n resolve({\n status: response.statusCode || 0,\n content: Buffer.concat(contentBuffers).toString(),\n isTimedOut: false,\n });\n });\n });\n\n const createTimeout = (timeout: number, content: string): NodeJS.Timeout => {\n return setTimeout(() => {\n req.destroy();\n\n resolve({\n status: 0,\n content,\n isTimedOut: true,\n });\n }, timeout);\n };\n\n connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');\n\n req.on('error', (error) => {\n clearTimeout(connectTimeout as NodeJS.Timeout);\n clearTimeout(responseTimeout!);\n resolve({ status: 0, content: error.message, isTimedOut: false });\n });\n\n req.once('response', () => {\n clearTimeout(connectTimeout as NodeJS.Timeout);\n responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');\n });\n\n if (request.data !== undefined) {\n req.write(request.data);\n }\n\n req.end();\n });\n }\n\n return { send };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAiB;AACjB,mBAAkB;AAClB,iBAAoB;AAepB,IAAM,eAAe,EAAE,WAAW,KAAK;AACvC,IAAM,mBAAmB,IAAI,YAAAA,QAAK,MAAM,YAAY;AACpD,IAAM,oBAAoB,IAAI,aAAAC,QAAM,MAAM,YAAY;AAE/C,SAAS,oBAAoB;AAAA,EAClC,OAAO;AAAA,EACP,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,mBAAmB,CAAC;AACtB,IAAgC,CAAC,GAAc;AAC7C,QAAM,YAAY,iBAAiB,mBAAmB;AACtD,QAAM,aAAa,kBAAkB,mBAAmB;AAExD,WAAS,KAAK,SAAwC;AACpD,WAAO,IAAI,QAAQ,CAAC,YAA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AgB;AAC7B,gBAAQ,EAAE,QAAQ,GAAG,SAAS,MAAM,SAAS,YAAY,MAAM,CAAC;AAAA,MAClE,CAAC;AAED,UAAI,KAAK,YAAY,MAAM;AACzB,qBAAa,cAAgC;AAC7C,0BAAkB,cAAc,QAAQ,iBAAiB,gBAAgB;AAAA,MAC3E,CAAC;AAED,UAAI,QAAQ,SAAS,QAAW;AAC9B,YAAI,MAAM,QAAQ,IAAI;AAAA,MACxB;AAEA,UAAI,IAAI;AAAA,IACV,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,KAAK;AAChB;","names":["http","https"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/createHttpRequester.ts"],"sourcesContent":["import http from 'http';\nimport https from 'https';\nimport { URL } from 'url';\n\nimport type { EndRequest, Requester, Response } from '@algolia/client-common';\n\nexport type CreateHttpRequesterOptions = Partial<{\n agent: http.Agent | https.Agent;\n httpAgent: http.Agent;\n httpsAgent: https.Agent;\n /**\n * RequestOptions to be merged with the end request, it will override default options if provided.\n */\n requesterOptions: https.RequestOptions;\n}>;\n\n// Global agents allow us to reuse the TCP protocol with multiple clients\nconst agentOptions = { keepAlive: true };\nconst defaultHttpAgent = new http.Agent(agentOptions);\nconst defaultHttpsAgent = new https.Agent(agentOptions);\n\nexport function createHttpRequester({\n agent: userGlobalAgent,\n httpAgent: userHttpAgent,\n httpsAgent: userHttpsAgent,\n requesterOptions = {},\n}: CreateHttpRequesterOptions = {}): Requester {\n const httpAgent = userHttpAgent || userGlobalAgent || defaultHttpAgent;\n const httpsAgent = userHttpsAgent || userGlobalAgent || defaultHttpsAgent;\n\n function send(request: EndRequest): Promise<Response> {\n return new Promise((resolve) => {\n let responseTimeout: NodeJS.Timeout | undefined;\n // eslint-disable-next-line prefer-const -- linter thinks this is not reassigned\n let connectTimeout: NodeJS.Timeout | undefined;\n const url = new URL(request.url);\n const path = url.search === null ? url.pathname : `${url.pathname}${url.search}`;\n const options: https.RequestOptions = {\n agent: url.protocol === 'https:' ? httpsAgent : httpAgent,\n hostname: url.hostname,\n path,\n method: request.method,\n ...requesterOptions,\n headers: {\n ...request.headers,\n ...requesterOptions.headers,\n },\n };\n\n if (url.port && !requesterOptions.port) {\n options.port = url.port;\n }\n\n const req = (url.protocol === 'https:' ? https : http).request(options, (response) => {\n let contentBuffers: Buffer[] = [];\n\n response.on('data', (chunk) => {\n contentBuffers = contentBuffers.concat(chunk);\n });\n\n response.on('end', () => {\n clearTimeout(connectTimeout as NodeJS.Timeout);\n clearTimeout(responseTimeout as NodeJS.Timeout);\n\n resolve({\n status: response.statusCode || 0,\n content: Buffer.concat(contentBuffers).toString(),\n isTimedOut: false,\n });\n });\n });\n\n const createTimeout = (timeout: number, content: string): NodeJS.Timeout => {\n return setTimeout(() => {\n req.destroy();\n\n resolve({\n status: 0,\n content,\n isTimedOut: true,\n });\n }, timeout);\n };\n\n connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');\n\n req.on('error', (error) => {\n clearTimeout(connectTimeout as NodeJS.Timeout);\n clearTimeout(responseTimeout!);\n resolve({ status: 0, content: error.message, isTimedOut: false });\n });\n\n req.once('response', () => {\n clearTimeout(connectTimeout as NodeJS.Timeout);\n responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');\n });\n\n if (request.data !== undefined) {\n req.write(request.data);\n }\n\n req.end();\n });\n }\n\n return { send };\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,WAAW;AAClB,SAAS,WAAW;AAepB,IAAM,eAAe,EAAE,WAAW,KAAK;AACvC,IAAM,mBAAmB,IAAI,KAAK,MAAM,YAAY;AACpD,IAAM,oBAAoB,IAAI,MAAM,MAAM,YAAY;AAE/C,SAAS,oBAAoB;AAAA,EAClC,OAAO;AAAA,EACP,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,mBAAmB,CAAC;AACtB,IAAgC,CAAC,GAAc;AAC7C,QAAM,YAAY,iBAAiB,mBAAmB;AACtD,QAAM,aAAa,kBAAkB,mBAAmB;AAExD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AAU;AACzB,qBAAa,cAAgC;AAC7C,qBAAa,eAAgB;AAC7B,gBAAQ,EAAE,QAAQ,GAAG,SAAS,MAAM,SAAS,YAAY,MAAM,CAAC;AAAA,MAClE,CAAC;AAED,UAAI,KAAK,YAAY,MAAM;AACzB,qBAAa,cAAgC;AAC7C,0BAAkB,cAAc,QAAQ,iBAAiB,gBAAgB;AAAA,MAC3E,CAAC;AAED,UAAI,QAAQ,SAAS,QAAW;AAC9B,YAAI,MAAM,QAAQ,IAAI;AAAA,MACxB;AAEA,UAAI,IAAI;AAAA,IACV,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,KAAK;AAChB;","names":[]}
1
+ {"version":3,"sources":["../src/createHttpRequester.ts"],"sourcesContent":["import http from 'http';\nimport https from 'https';\nimport { URL } from 'url';\n\nimport type { EndRequest, Requester, Response } from '@algolia/client-common';\n\nexport type CreateHttpRequesterOptions = Partial<{\n agent: http.Agent | https.Agent;\n httpAgent: http.Agent;\n httpsAgent: https.Agent;\n /**\n * RequestOptions to be merged with the end request, it will override default options if provided.\n */\n requesterOptions: https.RequestOptions;\n}>;\n\n// Global agents allow us to reuse the TCP protocol with multiple clients\nconst agentOptions = { keepAlive: true };\nconst defaultHttpAgent = new http.Agent(agentOptions);\nconst defaultHttpsAgent = new https.Agent(agentOptions);\n\nexport function createHttpRequester({\n agent: userGlobalAgent,\n httpAgent: userHttpAgent,\n httpsAgent: userHttpsAgent,\n requesterOptions = {},\n}: CreateHttpRequesterOptions = {}): Requester {\n const httpAgent = userHttpAgent || userGlobalAgent || defaultHttpAgent;\n const httpsAgent = userHttpsAgent || userGlobalAgent || defaultHttpsAgent;\n\n function send(request: EndRequest): Promise<Response> {\n return new Promise((resolve) => {\n let responseTimeout: NodeJS.Timeout | undefined;\n let connectTimeout: NodeJS.Timeout | undefined;\n const url = new URL(request.url);\n const path = url.search === null ? url.pathname : `${url.pathname}${url.search}`;\n const options: https.RequestOptions = {\n agent: url.protocol === 'https:' ? httpsAgent : httpAgent,\n hostname: url.hostname,\n path,\n method: request.method,\n ...requesterOptions,\n headers: {\n ...request.headers,\n ...requesterOptions.headers,\n },\n };\n\n if (url.port && !requesterOptions.port) {\n options.port = url.port;\n }\n\n const req = (url.protocol === 'https:' ? https : http).request(options, (response) => {\n let contentBuffers: Buffer[] = [];\n\n response.on('data', (chunk) => {\n contentBuffers = contentBuffers.concat(chunk);\n });\n\n response.on('end', () => {\n clearTimeout(connectTimeout as NodeJS.Timeout);\n clearTimeout(responseTimeout as NodeJS.Timeout);\n\n resolve({\n status: response.statusCode || 0,\n content: Buffer.concat(contentBuffers).toString(),\n isTimedOut: false,\n });\n });\n });\n\n const createTimeout = (timeout: number, content: string): NodeJS.Timeout => {\n return setTimeout(() => {\n req.destroy();\n\n resolve({\n status: 0,\n content,\n isTimedOut: true,\n });\n }, timeout);\n };\n\n connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');\n\n req.on('error', (error) => {\n clearTimeout(connectTimeout as NodeJS.Timeout);\n clearTimeout(responseTimeout!);\n resolve({ status: 0, content: error.message, isTimedOut: false });\n });\n\n req.once('response', () => {\n clearTimeout(connectTimeout as NodeJS.Timeout);\n responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');\n });\n\n if (request.data !== undefined) {\n req.write(request.data);\n }\n\n req.end();\n });\n }\n\n return { send };\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,WAAW;AAClB,SAAS,WAAW;AAepB,IAAM,eAAe,EAAE,WAAW,KAAK;AACvC,IAAM,mBAAmB,IAAI,KAAK,MAAM,YAAY;AACpD,IAAM,oBAAoB,IAAI,MAAM,MAAM,YAAY;AAE/C,SAAS,oBAAoB;AAAA,EAClC,OAAO;AAAA,EACP,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,mBAAmB,CAAC;AACtB,IAAgC,CAAC,GAAc;AAC7C,QAAM,YAAY,iBAAiB,mBAAmB;AACtD,QAAM,aAAa,kBAAkB,mBAAmB;AAExD,WAAS,KAAK,S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a,cAAgC;AAC7C,qBAAa,eAAgB;AAC7B,gBAAQ,EAAE,QAAQ,GAAG,SAAS,MAAM,SAAS,YAAY,MAAM,CAAC;AAAA,MAClE,CAAC;AAED,UAAI,KAAK,YAAY,MAAM;AACzB,qBAAa,cAAgC;AAC7C,0BAAkB,cAAc,QAAQ,iBAAiB,gBAAgB;AAAA,MAC3E,CAAC;AAED,UAAI,QAAQ,SAAS,QAAW;AAC9B,YAAI,MAAM,QAAQ,IAAI;AAAA,MACxB;AAEA,UAAI,IAAI;AAAA,IACV,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,KAAK;AAChB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algolia/requester-node-http",
3
- "version": "5.8.0",
3
+ "version": "5.8.1",
4
4
  "description": "Promise-based request library for node using the native http module.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "test:bundle": "publint . && attw --pack ."
35
35
  },
36
36
  "dependencies": {
37
- "@algolia/client-common": "5.8.0"
37
+ "@algolia/client-common": "5.8.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@arethetypeswrong/cli": "0.16.4",
@@ -138,7 +138,6 @@ describe('status code handling', () => {
138
138
  const data = Buffer.from('äöü');
139
139
 
140
140
  // create a test response stream that is chunked inside a unicode character
141
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
142
141
  function* generate() {
143
142
  yield data.subarray(0, 3);
144
143
  yield data.subarray(3);
@@ -31,7 +31,6 @@ export function createHttpRequester({
31
31
  function send(request: EndRequest): Promise<Response> {
32
32
  return new Promise((resolve) => {
33
33
  let responseTimeout: NodeJS.Timeout | undefined;
34
- // eslint-disable-next-line prefer-const -- linter thinks this is not reassigned
35
34
  let connectTimeout: NodeJS.Timeout | undefined;
36
35
  const url = new URL(request.url);
37
36
  const path = url.search === null ? url.pathname : `${url.pathname}${url.search}`;