Skip to content

Commit

Permalink
Merge pull request #1547 from actions/takost/update-http-client
Browse files Browse the repository at this point in the history
Add function to return proxy agent dispatcher for compatibility with latest `octokit` packages
  • Loading branch information
takost committed Oct 6, 2023
2 parents 0d63834 + 13e0ce9 commit c8d1588
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 77 deletions.
2 changes: 1 addition & 1 deletion packages/core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 16 additions & 9 deletions packages/github/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion packages/http-client/__tests__/proxy.test.ts
Expand Up @@ -3,6 +3,7 @@
import * as http from 'http'
import * as httpm from '../lib/'
import * as pm from '../lib/proxy'
import {ProxyAgent} from 'undici'
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
const proxy = require('proxy')

Expand All @@ -13,7 +14,7 @@ const _proxyUrl = 'http://127.0.0.1:8080'
describe('proxy', () => {
beforeAll(async () => {
// Start proxy server
_proxyServer = proxy()
_proxyServer = proxy.createProxy()
await new Promise<void>(resolve => {
const port = Number(_proxyUrl.split(':')[2])
_proxyServer.listen(port, () => resolve())
Expand Down Expand Up @@ -294,6 +295,15 @@ describe('proxy', () => {
expect(agent.proxyOptions.port).toBe('8080')
expect(agent.proxyOptions.proxyAuth).toBe('user:password')
})

it('ProxyAgent is returned when proxy setting are provided', 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)
})
})

function _clearVars(): void {
Expand Down
166 changes: 113 additions & 53 deletions packages/http-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c8d1588

Please sign in to comment.