@algolia/requester-node-http
Advanced tools
Comparing version 5.1.1 to 5.2.1
{ | ||
"name": "@algolia/requester-node-http", | ||
"version": "5.1.1", | ||
"version": "5.2.1", | ||
"description": "Promise-based request library for node using the native http module.", | ||
@@ -26,12 +26,12 @@ "repository": { | ||
"dependencies": { | ||
"@algolia/client-common": "5.1.1" | ||
"@algolia/client-common": "5.2.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/preset-env": "7.25.3", | ||
"@babel/preset-env": "7.25.4", | ||
"@babel/preset-typescript": "7.24.7", | ||
"@types/jest": "29.5.12", | ||
"@types/node": "20.14.14", | ||
"@types/node": "22.5.0", | ||
"jest": "29.7.0", | ||
"nock": "13.5.4", | ||
"ts-jest": "29.2.4", | ||
"nock": "13.5.5", | ||
"ts-jest": "29.2.5", | ||
"typescript": "5.5.4" | ||
@@ -38,0 +38,0 @@ }, |
@@ -82,3 +82,3 @@ import http from 'http'; | ||
}), | ||
expect.any(Function) | ||
expect.any(Function), | ||
); | ||
@@ -92,6 +92,3 @@ }); | ||
nock(testQueryBaseUrl, { reqheaders: headers }) | ||
.post('/foo') | ||
.query(testQueryHeader) | ||
.reply(200, body); | ||
nock(testQueryBaseUrl, { reqheaders: headers }).post('/foo').query(testQueryHeader).reply(200, body); | ||
@@ -106,6 +103,3 @@ const response = await requester.send(requestStub); | ||
nock(testQueryBaseUrl, { reqheaders: headers }) | ||
.post('/foo') | ||
.query(testQueryHeader) | ||
.reply(200, body); | ||
nock(testQueryBaseUrl, { reqheaders: headers }).post('/foo').query(testQueryHeader).reply(200, body); | ||
@@ -122,6 +116,3 @@ const response = await requester.send(requestStub); | ||
nock(testQueryBaseUrl, { reqheaders: headers }) | ||
.post('/foo') | ||
.query(testQueryHeader) | ||
.reply(300, reason); | ||
nock(testQueryBaseUrl, { reqheaders: headers }).post('/foo').query(testQueryHeader).reply(300, reason); | ||
@@ -140,6 +131,3 @@ const response = await requester.send(requestStub); | ||
nock(testQueryBaseUrl, { reqheaders: headers }) | ||
.post('/foo') | ||
.query(testQueryHeader) | ||
.reply(400, body); | ||
nock(testQueryBaseUrl, { reqheaders: headers }).post('/foo').query(testQueryHeader).reply(400, body); | ||
@@ -165,6 +153,3 @@ const response = await requester.send(requestStub); | ||
nock(testQueryBaseUrl, { reqheaders: headers }) | ||
.post('/foo') | ||
.query(testQueryHeader) | ||
.reply(200, testStream); | ||
nock(testQueryBaseUrl, { reqheaders: headers }).post('/foo').query(testQueryHeader).reply(200, testStream); | ||
@@ -171,0 +156,0 @@ const response = await requester.send(requestStub); |
@@ -37,4 +37,3 @@ import http from 'http'; | ||
const url = new URL(request.url); | ||
const path = | ||
url.search === null ? url.pathname : `${url.pathname}${url.search}`; | ||
const path = url.search === null ? url.pathname : `${url.pathname}${url.search}`; | ||
const options: https.RequestOptions = { | ||
@@ -56,28 +55,22 @@ agent: url.protocol === 'https:' ? httpsAgent : httpAgent, | ||
const req = (url.protocol === 'https:' ? https : http).request( | ||
options, | ||
(response) => { | ||
let contentBuffers: Buffer[] = []; | ||
const req = (url.protocol === 'https:' ? https : http).request(options, (response) => { | ||
let contentBuffers: Buffer[] = []; | ||
response.on('data', (chunk) => { | ||
contentBuffers = contentBuffers.concat(chunk); | ||
}); | ||
response.on('data', (chunk) => { | ||
contentBuffers = contentBuffers.concat(chunk); | ||
}); | ||
response.on('end', () => { | ||
clearTimeout(connectTimeout as NodeJS.Timeout); | ||
clearTimeout(responseTimeout as NodeJS.Timeout); | ||
response.on('end', () => { | ||
clearTimeout(connectTimeout as NodeJS.Timeout); | ||
clearTimeout(responseTimeout as NodeJS.Timeout); | ||
resolve({ | ||
status: response.statusCode || 0, | ||
content: Buffer.concat(contentBuffers).toString(), | ||
isTimedOut: false, | ||
}); | ||
resolve({ | ||
status: response.statusCode || 0, | ||
content: Buffer.concat(contentBuffers).toString(), | ||
isTimedOut: false, | ||
}); | ||
} | ||
); | ||
}); | ||
}); | ||
const createTimeout = ( | ||
timeout: number, | ||
content: string | ||
): NodeJS.Timeout => { | ||
const createTimeout = (timeout: number, content: string): NodeJS.Timeout => { | ||
return setTimeout(() => { | ||
@@ -94,6 +87,3 @@ req.destroy(); | ||
connectTimeout = createTimeout( | ||
request.connectTimeout, | ||
'Connection timeout' | ||
); | ||
connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout'); | ||
@@ -108,6 +98,3 @@ req.on('error', (error) => { | ||
clearTimeout(connectTimeout as NodeJS.Timeout); | ||
responseTimeout = createTimeout( | ||
request.responseTimeout, | ||
'Socket timeout' | ||
); | ||
responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout'); | ||
}); | ||
@@ -114,0 +101,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21527
491
+ Added@algolia/client-common@5.2.1(transitive)
- Removed@algolia/client-common@5.1.1(transitive)
Updated@algolia/client-common@5.2.1