@algolia/requester-node-http
Advanced tools
Comparing version 4.5.1 to 4.6.0
@@ -10,6 +10,8 @@ 'use strict'; | ||
/* eslint functional/prefer-readonly-type: 0 */ | ||
function createNodeHttpRequester({ agent: userGlobalAgent, httpAgent: userHttpAgent, httpsAgent: userHttpsAgent, } = {}) { | ||
const agentOptions = { keepAlive: true }; | ||
const httpAgent = userHttpAgent || userGlobalAgent || new http.Agent(agentOptions); | ||
const httpsAgent = userHttpsAgent || userGlobalAgent || new https.Agent(agentOptions); | ||
const agentOptions = { keepAlive: true }; | ||
const defaultHttpAgent = new http.Agent(agentOptions); | ||
const defaultHttpsAgent = new https.Agent(agentOptions); | ||
function createNodeHttpRequester({ agent: userGlobalAgent, httpAgent: userHttpAgent, httpsAgent: userHttpsAgent, requesterOptions = {}, } = {}) { | ||
const httpAgent = userHttpAgent || userGlobalAgent || defaultHttpAgent; | ||
const httpsAgent = userHttpsAgent || userGlobalAgent || defaultHttpsAgent; | ||
return { | ||
@@ -21,2 +23,3 @@ send(request) { | ||
const options = { | ||
...requesterOptions, | ||
agent: url.protocol === 'https:' ? httpsAgent : httpAgent, | ||
@@ -26,3 +29,6 @@ hostname: url.hostname, | ||
method: request.method, | ||
headers: request.headers, | ||
headers: { | ||
...(requesterOptions && requesterOptions.headers ? requesterOptions.headers : {}), | ||
...request.headers, | ||
}, | ||
...(url.port !== undefined ? { port: url.port || '' } : {}), | ||
@@ -29,0 +35,0 @@ }; |
@@ -7,3 +7,3 @@ /// <reference types="node" /> | ||
export declare function createNodeHttpRequester({ agent: userGlobalAgent, httpAgent: userHttpAgent, httpsAgent: userHttpsAgent, }?: NodeHttpRequesterOptions): Requester & Destroyable; | ||
export declare function createNodeHttpRequester({ agent: userGlobalAgent, httpAgent: userHttpAgent, httpsAgent: userHttpsAgent, requesterOptions, }?: NodeHttpRequesterOptions): Requester & Destroyable; | ||
@@ -14,4 +14,5 @@ export declare type NodeHttpRequesterOptions = { | ||
httpsAgent?: https.Agent; | ||
requesterOptions?: https.RequestOptions; | ||
}; | ||
export { } |
@@ -8,6 +8,8 @@ import * as http from 'http'; | ||
/* eslint functional/prefer-readonly-type: 0 */ | ||
function createNodeHttpRequester({ agent: userGlobalAgent, httpAgent: userHttpAgent, httpsAgent: userHttpsAgent, } = {}) { | ||
const agentOptions = { keepAlive: true }; | ||
const httpAgent = userHttpAgent || userGlobalAgent || new Agent(agentOptions); | ||
const httpsAgent = userHttpsAgent || userGlobalAgent || new Agent$1(agentOptions); | ||
const agentOptions = { keepAlive: true }; | ||
const defaultHttpAgent = new Agent(agentOptions); | ||
const defaultHttpsAgent = new Agent$1(agentOptions); | ||
function createNodeHttpRequester({ agent: userGlobalAgent, httpAgent: userHttpAgent, httpsAgent: userHttpsAgent, requesterOptions = {}, } = {}) { | ||
const httpAgent = userHttpAgent || userGlobalAgent || defaultHttpAgent; | ||
const httpsAgent = userHttpsAgent || userGlobalAgent || defaultHttpsAgent; | ||
return { | ||
@@ -19,2 +21,3 @@ send(request) { | ||
const options = { | ||
...requesterOptions, | ||
agent: url.protocol === 'https:' ? httpsAgent : httpAgent, | ||
@@ -24,3 +27,6 @@ hostname: url.hostname, | ||
method: request.method, | ||
headers: request.headers, | ||
headers: { | ||
...(requesterOptions && requesterOptions.headers ? requesterOptions.headers : {}), | ||
...request.headers, | ||
}, | ||
...(url.port !== undefined ? { port: url.port || '' } : {}), | ||
@@ -27,0 +33,0 @@ }; |
{ | ||
"name": "@algolia/requester-node-http", | ||
"version": "4.5.1", | ||
"version": "4.6.0", | ||
"private": false, | ||
@@ -20,4 +20,4 @@ "description": "Promise-based request library for node using the native http module.", | ||
"dependencies": { | ||
"@algolia/requester-common": "4.5.1" | ||
"@algolia/requester-common": "4.6.0" | ||
} | ||
} |
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
9211
181
+ Added@algolia/requester-common@4.6.0(transitive)
- Removed@algolia/requester-common@4.5.1(transitive)