-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Won't use HTTP(S)_PROXY env var if proxy explicitly set to null.
- Loading branch information
1 parent
8a0e2d6
commit e86377c
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var server = require('./server') | ||
, events = require('events') | ||
, stream = require('stream') | ||
, assert = require('assert') | ||
, fs = require('fs') | ||
, request = require('../index') | ||
, path = require('path') | ||
, util = require('util') | ||
; | ||
|
||
var port = 6768 | ||
, called = false | ||
, proxiedHost = 'google.com' | ||
; | ||
|
||
// set up environment variable | ||
process.env.HTTP_PROXY = 'http://localhost:'+port; | ||
|
||
var s = server.createServer(port) | ||
s.listen(port, function () { | ||
s.on('http://google.com/', function (req, res) { | ||
called = true | ||
assert.equal(req.headers.host, proxiedHost) | ||
res.writeHeader(200) | ||
res.end() | ||
}) | ||
request ({ | ||
url: 'http://'+proxiedHost, | ||
// should not read from HTTP_PROXY env var | ||
proxy: null, | ||
timeout: 500, | ||
}, function (err, res, body) { | ||
s.close() | ||
}) | ||
}) | ||
|
||
process.on('exit', function () { | ||
assert.ok(!called, 'the request must not be made to the proxy server') | ||
}) |