mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 12:58:19 +02:00
lib: noproxy support, match proxy detection to request
PR-URL: https://github.com/nodejs/node-gyp/pull/1978 Reviewed-By: Rod Vagg <rod@vagg.org>
This commit is contained in:
parent
345c70e56d
commit
3bcba2a01a
5 changed files with 192 additions and 5 deletions
|
@ -90,6 +90,101 @@ test('download over https with custom ca', function (t) {
|
|||
})
|
||||
})
|
||||
|
||||
test('download over http with proxy', function (t) {
|
||||
t.plan(2)
|
||||
|
||||
var server = http.createServer(function (req, res) {
|
||||
t.strictEqual(req.headers['user-agent'],
|
||||
'node-gyp v42 (node ' + process.version + ')')
|
||||
res.end('ok')
|
||||
pserver.close(function () {
|
||||
server.close()
|
||||
})
|
||||
})
|
||||
|
||||
var pserver = http.createServer(function (req, res) {
|
||||
t.strictEqual(req.headers['user-agent'],
|
||||
'node-gyp v42 (node ' + process.version + ')')
|
||||
res.end('proxy ok')
|
||||
server.close(function () {
|
||||
pserver.close()
|
||||
})
|
||||
})
|
||||
|
||||
var host = 'localhost'
|
||||
server.listen(0, host, function () {
|
||||
var port = this.address().port
|
||||
pserver.listen(port + 1, host, function () {
|
||||
var gyp = {
|
||||
opts: {
|
||||
proxy: 'http://' + host + ':' + (port + 1)
|
||||
},
|
||||
version: '42'
|
||||
}
|
||||
var url = 'http://' + host + ':' + port
|
||||
var req = install.test.download(gyp, {}, url)
|
||||
req.on('response', function (res) {
|
||||
var body = ''
|
||||
res.setEncoding('utf8')
|
||||
res.on('data', function (data) {
|
||||
body += data
|
||||
})
|
||||
res.on('end', function () {
|
||||
t.strictEqual(body, 'proxy ok')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('download over http with noproxy', function (t) {
|
||||
t.plan(2)
|
||||
|
||||
var server = http.createServer(function (req, res) {
|
||||
t.strictEqual(req.headers['user-agent'],
|
||||
'node-gyp v42 (node ' + process.version + ')')
|
||||
res.end('ok')
|
||||
pserver.close(function () {
|
||||
server.close()
|
||||
})
|
||||
})
|
||||
|
||||
var pserver = http.createServer(function (req, res) {
|
||||
t.strictEqual(req.headers['user-agent'],
|
||||
'node-gyp v42 (node ' + process.version + ')')
|
||||
res.end('proxy ok')
|
||||
server.close(function () {
|
||||
pserver.close()
|
||||
})
|
||||
})
|
||||
|
||||
var host = 'localhost'
|
||||
server.listen(0, host, function () {
|
||||
var port = this.address().port
|
||||
pserver.listen(port + 1, host, function () {
|
||||
var gyp = {
|
||||
opts: {
|
||||
proxy: 'http://' + host + ':' + (port + 1),
|
||||
noproxy: 'localhost'
|
||||
},
|
||||
version: '42'
|
||||
}
|
||||
var url = 'http://' + host + ':' + port
|
||||
var req = install.test.download(gyp, {}, url)
|
||||
req.on('response', function (res) {
|
||||
var body = ''
|
||||
res.setEncoding('utf8')
|
||||
res.on('data', function (data) {
|
||||
body += data
|
||||
})
|
||||
res.on('end', function () {
|
||||
t.strictEqual(body, 'ok')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('download with missing cafile', function (t) {
|
||||
t.plan(1)
|
||||
var gyp = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue