Compare commits

..

3 Commits

Author SHA1 Message Date
Tatyana Kostromskaya 71bc34b2d5 . 2023-10-04 09:30:46 +00:00
Tatyana Kostromskaya c25ba9aa99 Merge branch 'main' into takost/addfetchmethod 2023-09-28 11:07:01 +00:00
Tatyana Kostromskaya 9f29c14937 . 2023-09-26 11:01:17 +00:00
11 changed files with 158 additions and 117 deletions
@@ -50,6 +50,7 @@ describe('@actions/github', () => {
}
const octokit = getOctokit(token)
const branch = await octokit.rest.repos.getBranch({
owner: 'actions',
repo: 'toolkit',
@@ -65,6 +66,17 @@ describe('@actions/github', () => {
return
}
process.env['https_proxy'] = proxyUrl
// const myFetch: typeof undiciFetch = (url, opts) => {
// return undiciFetch(url, {
// ...opts,
// dispatcher: new ProxyAgent({
// uri: proxyUrl,
// keepAliveTimeout: 10,
// keepAliveMaxTimeout: 10,
// }),
// });
// };
const octokit = getOctokit(token)
const repository = await octokit.graphql(
+63 -38
View File
@@ -1,42 +1,34 @@
{
"name": "@actions/github",
"version": "6.0.2",
"version": "5.1.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@actions/github",
"version": "6.0.2",
"version": "5.1.1",
"license": "MIT",
"dependencies": {
"@actions/http-client": "file:actions-http-client-3.0.3.tgz",
"@actions/http-client": "file:../http-client/actions-http-client-3.0.0.tgz",
"@octokit/core": "^4.2.4",
"@octokit/plugin-paginate-rest": "^6.1.2",
"@octokit/plugin-rest-endpoint-methods": "^7.2.3",
"undici": "^5.25.2"
"@octokit/plugin-rest-endpoint-methods": "^7.2.3"
},
"devDependencies": {
"@types/proxy": "^1.0.1",
"proxy": "^2.1.1"
"proxy": "^2.1.1",
"undici": "^5.25.2"
}
},
"node_modules/@actions/http-client": {
"version": "3.0.3",
"resolved": "file:actions-http-client-3.0.3.tgz",
"integrity": "sha512-oD3QP51ndN4IMUntw5mWcP7yZ/7c9cpLRejqbUwe9cT5vC72bWHLr5odlPzE+RAsoEVZMEkKazJbCjXdTzq8og==",
"version": "3.0.0",
"resolved": "file:../http-client/actions-http-client-3.0.0.tgz",
"integrity": "sha512-HiloxFqJ4f0Z34H7pcqYcYb+UK+CqUKJmNY245AITh9HyJMvLz9wCrb5J+UWO6S63klrJBnzYBguTNUYrbCNrQ==",
"license": "MIT",
"dependencies": {
"tunnel": "^0.0.6"
}
},
"node_modules/@fastify/busboy": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz",
"integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==",
"engines": {
"node": ">=14"
}
},
"node_modules/@octokit/auth-token": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.4.tgz",
@@ -173,9 +165,9 @@
}
},
"node_modules/@types/node": {
"version": "20.8.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.2.tgz",
"integrity": "sha512-Vvycsc9FQdwhxE3y3DzeIxuEJbWGDsnrxvMADzTDF/lcdR9/K+AQIeAghTQsHtotg/q0j3WEOYS/jQgSdWue3w==",
"version": "20.7.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.1.tgz",
"integrity": "sha512-LT+OIXpp2kj4E2S/p91BMe+VgGX2+lfO+XTpfXhh+bCk2LkQtHZSub8ewFBMGP5ClysPjTDFa4sMI8Q3n4T0wg==",
"dev": true
},
"node_modules/@types/proxy": {
@@ -225,6 +217,18 @@
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz",
"integrity": "sha512-/6FKxSTWoJdbsLDF8tdIjaRiFXiE6UHsEHE3OPI/cwPURCVi1ukP0gmLn7XWEiFk5TcwQjjY5PWsU+j+tgXgmw=="
},
"node_modules/busboy": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
"dev": true,
"dependencies": {
"streamsearch": "^1.1.0"
},
"engines": {
"node": ">=10.16.0"
}
},
"node_modules/camelcase": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
@@ -376,6 +380,15 @@
"node": ">= 14"
}
},
"node_modules/streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
"dev": true,
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
@@ -402,11 +415,12 @@
}
},
"node_modules/undici": {
"version": "5.25.4",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.4.tgz",
"integrity": "sha512-450yJxT29qKMf3aoudzFpIciqpx6Pji3hEWaXqXmanbXF58LTAGCKxcJjxMXWu3iG+Mudgo3ZUfDB6YDFd/dAw==",
"version": "5.25.2",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.2.tgz",
"integrity": "sha512-tch8RbCfn1UUH1PeVCXva4V8gDpGAud/w0WubD6sHC46vYQ3KDxL+xv1A2UxK0N6jrVedutuPHxe1XIoqerwMw==",
"dev": true,
"dependencies": {
"@fastify/busboy": "^2.0.0"
"busboy": "^1.6.0"
},
"engines": {
"node": ">=14.0"
@@ -439,17 +453,12 @@
},
"dependencies": {
"@actions/http-client": {
"version": "file:actions-http-client-3.0.3.tgz",
"integrity": "sha512-oD3QP51ndN4IMUntw5mWcP7yZ/7c9cpLRejqbUwe9cT5vC72bWHLr5odlPzE+RAsoEVZMEkKazJbCjXdTzq8og==",
"version": "file:../http-client/actions-http-client-3.0.0.tgz",
"integrity": "sha512-HiloxFqJ4f0Z34H7pcqYcYb+UK+CqUKJmNY245AITh9HyJMvLz9wCrb5J+UWO6S63klrJBnzYBguTNUYrbCNrQ==",
"requires": {
"tunnel": "^0.0.6"
}
},
"@fastify/busboy": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz",
"integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ=="
},
"@octokit/auth-token": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.4.tgz",
@@ -558,9 +567,9 @@
}
},
"@types/node": {
"version": "20.8.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.2.tgz",
"integrity": "sha512-Vvycsc9FQdwhxE3y3DzeIxuEJbWGDsnrxvMADzTDF/lcdR9/K+AQIeAghTQsHtotg/q0j3WEOYS/jQgSdWue3w==",
"version": "20.7.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.1.tgz",
"integrity": "sha512-LT+OIXpp2kj4E2S/p91BMe+VgGX2+lfO+XTpfXhh+bCk2LkQtHZSub8ewFBMGP5ClysPjTDFa4sMI8Q3n4T0wg==",
"dev": true
},
"@types/proxy": {
@@ -604,6 +613,15 @@
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz",
"integrity": "sha512-/6FKxSTWoJdbsLDF8tdIjaRiFXiE6UHsEHE3OPI/cwPURCVi1ukP0gmLn7XWEiFk5TcwQjjY5PWsU+j+tgXgmw=="
},
"busboy": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
"dev": true,
"requires": {
"streamsearch": "^1.1.0"
}
},
"camelcase": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
@@ -712,6 +730,12 @@
"debug": "^4.3.4"
}
},
"streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
"dev": true
},
"supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
@@ -732,11 +756,12 @@
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
},
"undici": {
"version": "5.25.4",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.4.tgz",
"integrity": "sha512-450yJxT29qKMf3aoudzFpIciqpx6Pji3hEWaXqXmanbXF58LTAGCKxcJjxMXWu3iG+Mudgo3ZUfDB6YDFd/dAw==",
"version": "5.25.2",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.2.tgz",
"integrity": "sha512-tch8RbCfn1UUH1PeVCXva4V8gDpGAud/w0WubD6sHC46vYQ3KDxL+xv1A2UxK0N6jrVedutuPHxe1XIoqerwMw==",
"dev": true,
"requires": {
"@fastify/busboy": "^2.0.0"
"busboy": "^1.6.0"
}
},
"universal-user-agent": {
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@actions/github",
"version": "6.0.2",
"version": "5.1.1",
"description": "Actions github lib",
"keywords": [
"github",
@@ -38,14 +38,14 @@
"url": "https://github.com/actions/toolkit/issues"
},
"dependencies": {
"@actions/http-client": "file:actions-http-client-3.0.3.tgz",
"@actions/http-client": "file:../http-client/actions-http-client-3.0.0.tgz",
"@octokit/core": "^4.2.4",
"@octokit/plugin-paginate-rest": "^6.1.2",
"@octokit/plugin-rest-endpoint-methods": "^7.2.3",
"undici": "^5.25.2"
"@octokit/plugin-rest-endpoint-methods": "^7.2.3"
},
"devDependencies": {
"@types/proxy": "^1.0.1",
"proxy": "^2.1.1"
"proxy": "^2.1.1",
"undici": "^5.25.2"
}
}
+7 -6
View File
@@ -1,6 +1,7 @@
import * as http from 'http'
import * as httpClient from '@actions/http-client'
import {OctokitOptions} from '@octokit/core/dist-types/types'
import { ProxyServer, createProxy } from "proxy";
import { ProxyAgent, Agent, fetch as undiciFetch } from "undici";
export function getAuthString(
@@ -21,20 +22,20 @@ export function getProxyAgent(destinationUrl: string): http.Agent {
return hc.getAgent(destinationUrl)
}
export function getProxyAgentDispatcher(destinationUrl: string): ProxyAgent | undefined {
export function getNewProxyAgent(destinationUrl: string): ProxyAgent | Agent {
const hc = new httpClient.HttpClient()
return hc.getAgentDispatcher(destinationUrl)
return hc.getNewAgent(destinationUrl)
}
export function getProxyFetch(destinationUrl): any {
const httpAgent = getProxyAgentDispatcher(destinationUrl)
const proxyFetch: typeof undiciFetch = (url, opts) => {
export function getProxyFetchAgent(destinationUrl): any {
const httpAgent = getNewProxyAgent(destinationUrl)
const myFetch: typeof undiciFetch = (url, opts) => {
return undiciFetch(url, {
...opts,
dispatcher: httpAgent,
});
};
return proxyFetch;
return myFetch;
}
export function getApiBaseUrl(): string {
+1 -2
View File
@@ -13,8 +13,7 @@ const baseUrl = Utils.getApiBaseUrl()
export const defaults: OctokitOptions = {
baseUrl,
request: {
agent: Utils.getProxyAgent(baseUrl),
fetch: Utils.getProxyFetch(baseUrl)
fetch: Utils.getProxyFetchAgent(baseUrl)
}
}
+1 -19
View File
@@ -3,7 +3,6 @@
import * as http from 'http'
import * as httpm from '../lib/'
import * as pm from '../lib/proxy'
import { ProxyAgent, Agent, fetch as undiciFetch } from "undici";
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
const proxy = require('proxy')
@@ -14,7 +13,7 @@ const _proxyUrl = 'http://127.0.0.1:8080'
describe('proxy', () => {
beforeAll(async () => {
// Start proxy server
_proxyServer = proxy.createProxy()
_proxyServer = proxy()
await new Promise<void>(resolve => {
const port = Number(_proxyUrl.split(':')[2])
_proxyServer.listen(port, () => resolve())
@@ -295,23 +294,6 @@ describe('proxy', () => {
expect(agent.proxyOptions.port).toBe('8080')
expect(agent.proxyOptions.proxyAuth).toBe('user:password')
})
it('proxy settings return ProxyAgent', async () => {
process.env['https_proxy'] = 'http://127.0.0.1:8080'
const httpClient = new httpm.HttpClient()
const agent = httpClient.getAgentDispatcher('https://some-url')
// eslint-disable-next-line no-console
console.log(agent)
expect(agent instanceof ProxyAgent).toBe(true)
})
// it('proxyAuth is set in tunnel agent when authentication is provided', async () => {
// const httpClient = new httpm.HttpClient()
// const agent: Agent | ProxyAgent = httpClient.getAgentDispatcher('https://some-url')
// // eslint-disable-next-line no-console
// console.log(agent)
// expect(agent instanceof Agent).toBe(true)
// })
})
function _clearVars(): void {
Binary file not shown.
Binary file not shown.
+49 -28
View File
@@ -1,31 +1,22 @@
{
"name": "@actions/http-client",
"version": "3.0.3",
"version": "3.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@actions/http-client",
"version": "3.0.3",
"version": "3.0.0",
"license": "MIT",
"dependencies": {
"tunnel": "^0.0.6"
},
"devDependencies": {
"@types/node": "20.7.1",
"@types/proxy": "^1.0.1",
"@types/node": "^20.7.1",
"@types/proxy": "^1.0.2",
"@types/tunnel": "0.0.3",
"proxy": "^2.1.1",
"undici": "^5.25.4"
}
},
"node_modules/@fastify/busboy": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz",
"integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==",
"dev": true,
"engines": {
"node": ">=14"
"undici": "^5.25.2"
}
},
"node_modules/@types/node": {
@@ -85,6 +76,18 @@
"integrity": "sha512-GFj8iVxo9onSU6BnnQvVwqvxh60UcSHJEDnIk3z4B6iOjsKSmqe+ibW0Rsz7YO7IE1HG3D3tqCNIidP46SZVdQ==",
"dev": true
},
"node_modules/busboy": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
"dev": true,
"dependencies": {
"streamsearch": "^1.1.0"
},
"engines": {
"node": ">=10.16.0"
}
},
"node_modules/camelcase": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
@@ -196,6 +199,15 @@
"node": ">= 14"
}
},
"node_modules/streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
"dev": true,
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
@@ -217,12 +229,12 @@
}
},
"node_modules/undici": {
"version": "5.25.4",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.4.tgz",
"integrity": "sha512-450yJxT29qKMf3aoudzFpIciqpx6Pji3hEWaXqXmanbXF58LTAGCKxcJjxMXWu3iG+Mudgo3ZUfDB6YDFd/dAw==",
"version": "5.25.2",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.2.tgz",
"integrity": "sha512-tch8RbCfn1UUH1PeVCXva4V8gDpGAud/w0WubD6sHC46vYQ3KDxL+xv1A2UxK0N6jrVedutuPHxe1XIoqerwMw==",
"dev": true,
"dependencies": {
"@fastify/busboy": "^2.0.0"
"busboy": "^1.6.0"
},
"engines": {
"node": ">=14.0"
@@ -230,12 +242,6 @@
}
},
"dependencies": {
"@fastify/busboy": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz",
"integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==",
"dev": true
},
"@types/node": {
"version": "20.7.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.1.tgz",
@@ -287,6 +293,15 @@
"integrity": "sha512-GFj8iVxo9onSU6BnnQvVwqvxh60UcSHJEDnIk3z4B6iOjsKSmqe+ibW0Rsz7YO7IE1HG3D3tqCNIidP46SZVdQ==",
"dev": true
},
"busboy": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
"dev": true,
"requires": {
"streamsearch": "^1.1.0"
}
},
"camelcase": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
@@ -369,6 +384,12 @@
"debug": "^4.3.4"
}
},
"streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
"dev": true
},
"supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
@@ -384,12 +405,12 @@
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
},
"undici": {
"version": "5.25.4",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.4.tgz",
"integrity": "sha512-450yJxT29qKMf3aoudzFpIciqpx6Pji3hEWaXqXmanbXF58LTAGCKxcJjxMXWu3iG+Mudgo3ZUfDB6YDFd/dAw==",
"version": "5.25.2",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.2.tgz",
"integrity": "sha512-tch8RbCfn1UUH1PeVCXva4V8gDpGAud/w0WubD6sHC46vYQ3KDxL+xv1A2UxK0N6jrVedutuPHxe1XIoqerwMw==",
"dev": true,
"requires": {
"@fastify/busboy": "^2.0.0"
"busboy": "^1.6.0"
}
}
}
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@actions/http-client",
"version": "3.0.3",
"version": "3.0.0",
"description": "Actions Http Client",
"keywords": [
"github",
@@ -39,11 +39,11 @@
"url": "https://github.com/actions/toolkit/issues"
},
"devDependencies": {
"@types/node": "20.7.1",
"@types/node": "^20.7.1",
"@types/proxy": "^1.0.2",
"@types/tunnel": "0.0.3",
"proxy": "^2.1.1",
"undici": "^5.25.4",
"@types/proxy": "^1.0.1"
"undici": "^5.25.2"
},
"dependencies": {
"tunnel": "^0.0.6"
+16 -15
View File
@@ -137,9 +137,9 @@ export class HttpClient {
private _allowRetries = false
private _maxRetries = 1
private _agent: any
private _newAgent: any
private _proxyAgent: any
private _agentDispatcher: any
private _proxyAgentDispatcher: any
private _newProxyAgent: any
private _keepAlive = false
private _disposed = false
@@ -567,15 +567,15 @@ export class HttpClient {
return this._getAgent(parsedUrl)
}
getAgentDispatcher(serverUrl: string): ProxyAgent | undefined {
getNewAgent(serverUrl: string): ProxyAgent | Agent {
const parsedUrl = new URL(serverUrl)
const proxyUrl = pm.getProxyUrl(parsedUrl)
const useProxy = proxyUrl && proxyUrl.hostname
if (useProxy) {
return this._getProxyAgentDispatcher(parsedUrl, proxyUrl)
return this._getProxyAgent(parsedUrl)
}
else {
return;
return this._getNewAgent(parsedUrl)
}
}
@@ -694,7 +694,7 @@ export class HttpClient {
// if reusing agent across request and tunneling agent isn't assigned create a new agent
if (this._keepAlive && !agent) {
const options = {keepAlive: this._keepAlive, maxSockets}
const options = { keepAlive: this._keepAlive, maxSockets }
agent = usingSsl ? new https.Agent(options) : new http.Agent(options)
this._agent = agent
}
@@ -716,16 +716,17 @@ export class HttpClient {
return agent
}
private _getProxyAgentDispatcher(parsedUrl: URL, proxyUrl: URL): ProxyAgent {
private _getProxyAgent(parsedUrl: URL): ProxyAgent {
let proxyAgent
const proxyUrl = pm.getProxyUrl(parsedUrl)
const useProxy = proxyUrl && proxyUrl.hostname
if (this._keepAlive && useProxy) {
proxyAgent = this._proxyAgentDispatcher
proxyAgent = this._newProxyAgent
}
if (this._keepAlive && !useProxy) {
proxyAgent = this._agentDispatcher
proxyAgent = this._newAgent
}
// if agent is already assigned use that agent.
@@ -748,7 +749,7 @@ export class HttpClient {
token: `${proxyUrl.username}:${proxyUrl.password}`
}),
})
this._proxyAgentDispatcher = proxyAgent
this._newProxyAgent = proxyAgent
}
if (usingSsl && this._ignoreSslError) {
@@ -763,11 +764,11 @@ export class HttpClient {
return proxyAgent
}
private _getAgentDispatcher(parsedUrl: URL): Agent {
private _getNewAgent(parsedUrl: URL): Agent {
let agent;
if (this._keepAlive) {
agent = this._agentDispatcher
agent = this._newAgent
}
// if agent is already assigned use that agent.
@@ -782,13 +783,13 @@ export class HttpClient {
}
// if reusing agent across request and tunneling agent isn't assigned create a new agent
if (!agent) {
if (this._keepAlive && !agent) {
agent = new Agent(
{
pipelining: (!this._keepAlive ? 0 : 1),
}
)
this._agentDispatcher = agent
this._newAgent = agent
}
if (usingSsl && this._ignoreSslError) {
@@ -885,5 +886,5 @@ export class HttpClient {
}
}
const lowercaseKeys = (obj: {[index: string]: any}): any =>
const lowercaseKeys = (obj: { [index: string]: any }): any =>
Object.keys(obj).reduce((c: any, k) => ((c[k.toLowerCase()] = obj[k]), c), {})