mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2025-08-22 13:09:27 +08:00
Better ipv6 definitions
This commit is contained in:
parent
5d8e1ee68b
commit
b511bc151f
@ -28,7 +28,7 @@ describe('proxy', () => {
|
|||||||
_clearVars()
|
_clearVars()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {})
|
afterEach(() => { })
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
_clearVars()
|
_clearVars()
|
||||||
@ -239,7 +239,7 @@ describe('proxy', () => {
|
|||||||
|
|
||||||
it('HttpClient bypasses proxy for loopback addresses (localhost, ::1, 127.*)', async () => {
|
it('HttpClient bypasses proxy for loopback addresses (localhost, ::1, 127.*)', async () => {
|
||||||
// setup a server listening on localhost:8091
|
// setup a server listening on localhost:8091
|
||||||
const server = http.createServer(function(request, response) {
|
const server = http.createServer(function (request, response) {
|
||||||
response.writeHead(200)
|
response.writeHead(200)
|
||||||
request.pipe(response)
|
request.pipe(response)
|
||||||
})
|
})
|
||||||
@ -247,12 +247,24 @@ describe('proxy', () => {
|
|||||||
try {
|
try {
|
||||||
process.env['http_proxy'] = _proxyUrl
|
process.env['http_proxy'] = _proxyUrl
|
||||||
const httpClient = new httpm.HttpClient()
|
const httpClient = new httpm.HttpClient()
|
||||||
const res: httpm.HttpClientResponse = await httpClient.get(
|
let res = await httpClient.get(
|
||||||
'http://localhost:8091'
|
'http://localhost:8091'
|
||||||
)
|
)
|
||||||
expect(res.message.statusCode).toBe(200)
|
expect(res.message.statusCode).toBe(200)
|
||||||
const body: string = await res.readBody()
|
res = await httpClient.get(
|
||||||
expect(body).toEqual('')
|
'http://127.0.0.1:8091'
|
||||||
|
)
|
||||||
|
expect(res.message.statusCode).toBe(200)
|
||||||
|
|
||||||
|
// no support for ipv6 for now
|
||||||
|
expect(httpClient.get(
|
||||||
|
'http://[::1]:8091')).rejects.toThrow()
|
||||||
|
|
||||||
|
// ipv6 not supported atm
|
||||||
|
// expect(async () => await httpClient.get(
|
||||||
|
// 'http://[::1]:8091'
|
||||||
|
// )).toThrow()
|
||||||
|
|
||||||
// proxy at _proxyUrl was ignored
|
// proxy at _proxyUrl was ignored
|
||||||
expect(_proxyConnects).toEqual([])
|
expect(_proxyConnects).toEqual([])
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -77,6 +77,7 @@ function isLoopbackAddress(host: string): boolean {
|
|||||||
return (
|
return (
|
||||||
hostLower === 'localhost' ||
|
hostLower === 'localhost' ||
|
||||||
hostLower.startsWith('127.') ||
|
hostLower.startsWith('127.') ||
|
||||||
hostLower.startsWith('::1')
|
hostLower.startsWith('[::1]') ||
|
||||||
|
hostLower.startsWith('[0:0:0:0:0:0:0:1]')
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user