Added proxy support (#1260)

This commit is contained in:
Tomas Della Vedova
2020-08-03 11:39:24 +02:00
committed by GitHub
parent 629894adba
commit 26238634a7
15 changed files with 344 additions and 6 deletions

View File

@ -24,6 +24,7 @@ const { inspect } = require('util')
const { createGzip, createDeflate } = require('zlib')
const { URL } = require('url')
const { Agent } = require('http')
const hpagent = require('hpagent')
const intoStream = require('into-stream')
const { buildServer } = require('../utils')
const Connection = require('../../lib/Connection')
@ -975,3 +976,25 @@ test('Should correctly resolve request pathname', t => {
'/test/hello'
)
})
test('Proxy agent (http)', t => {
t.plan(1)
const connection = new Connection({
url: new URL('http://localhost:9200'),
proxy: 'http://localhost:8080'
})
t.true(connection.agent instanceof hpagent.HttpProxyAgent)
})
test('Proxy agent (https)', t => {
t.plan(1)
const connection = new Connection({
url: new URL('https://localhost:9200'),
proxy: 'http://localhost:8080'
})
t.true(connection.agent instanceof hpagent.HttpsProxyAgent)
})