@algolia/requester-node-http
Advanced tools
Comparing version 4.0.0-beta.10 to 4.0.0-beta.11
@@ -9,3 +9,7 @@ 'use strict'; | ||
/* eslint sonarjs/cognitive-complexity: 0 */ // --> | ||
function createNodeHttpRequester() { | ||
const agentOptions = { keepAlive: true }; | ||
const httpAgent = new http.Agent(agentOptions); | ||
const httpsAgent = new https.Agent(agentOptions); | ||
return { | ||
@@ -17,4 +21,5 @@ send(request) { | ||
const options = { | ||
hostname: url.hostname || '', | ||
path: path || '', | ||
agent: url.protocol === 'https:' ? httpsAgent : httpAgent, | ||
hostname: url.hostname, | ||
path, | ||
method: request.method, | ||
@@ -33,4 +38,7 @@ headers: request.headers, | ||
clearTimeout(responseTimeout); | ||
const status = response.statusCode === undefined ? 0 : response.statusCode; | ||
resolve({ status, content, isTimedOut: false }); | ||
resolve({ | ||
status: response.statusCode || 0, | ||
content, | ||
isTimedOut: false, | ||
}); | ||
}); | ||
@@ -60,6 +68,13 @@ }); | ||
}); | ||
req.write(request.data); | ||
if (request.data !== undefined) { | ||
req.write(request.data); | ||
} | ||
req.end(); | ||
}); | ||
}, | ||
destroy() { | ||
httpAgent.destroy(); | ||
httpsAgent.destroy(); | ||
return Promise.resolve(); | ||
}, | ||
}; | ||
@@ -66,0 +81,0 @@ } |
@@ -0,5 +1,6 @@ | ||
import { Destroyable } from '@algolia/requester-common'; | ||
import { Requester } from '@algolia/requester-common'; | ||
export declare function createNodeHttpRequester(): Requester; | ||
export declare function createNodeHttpRequester(): Requester & Destroyable; | ||
export { } |
import * as http from 'http'; | ||
import { Agent } from 'http'; | ||
import * as https from 'https'; | ||
import { Agent as Agent$1 } from 'https'; | ||
import { parse } from 'url'; | ||
/* eslint sonarjs/cognitive-complexity: 0 */ // --> | ||
function createNodeHttpRequester() { | ||
const agentOptions = { keepAlive: true }; | ||
const httpAgent = new Agent(agentOptions); | ||
const httpsAgent = new Agent$1(agentOptions); | ||
return { | ||
@@ -12,4 +18,5 @@ send(request) { | ||
const options = { | ||
hostname: url.hostname || '', | ||
path: path || '', | ||
agent: url.protocol === 'https:' ? httpsAgent : httpAgent, | ||
hostname: url.hostname, | ||
path, | ||
method: request.method, | ||
@@ -28,4 +35,7 @@ headers: request.headers, | ||
clearTimeout(responseTimeout); | ||
const status = response.statusCode === undefined ? 0 : response.statusCode; | ||
resolve({ status, content, isTimedOut: false }); | ||
resolve({ | ||
status: response.statusCode || 0, | ||
content, | ||
isTimedOut: false, | ||
}); | ||
}); | ||
@@ -55,6 +65,13 @@ }); | ||
}); | ||
req.write(request.data); | ||
if (request.data !== undefined) { | ||
req.write(request.data); | ||
} | ||
req.end(); | ||
}); | ||
}, | ||
destroy() { | ||
httpAgent.destroy(); | ||
httpsAgent.destroy(); | ||
return Promise.resolve(); | ||
}, | ||
}; | ||
@@ -61,0 +78,0 @@ } |
{ | ||
"name": "@algolia/requester-node-http", | ||
"version": "4.0.0-beta.10", | ||
"version": "4.0.0-beta.11", | ||
"private": false, | ||
@@ -16,4 +16,4 @@ "description": "Promise-based request library for node using the native http module.", | ||
"dependencies": { | ||
"@algolia/requester-common": "4.0.0-beta.10" | ||
"@algolia/requester-common": "4.0.0-beta.11" | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
7498
156
6
+ Added@algolia/requester-common@4.0.0-beta.11(transitive)
- Removed@algolia/requester-common@4.0.0-beta.10(transitive)