Skip to content

Commit ab42124

Browse files
committed
Merge pull request #903 from nodejitsu/ntlm-authentication
[example] add an example for NTLM authentication
2 parents b5a6d0e + 5d593e8 commit ab42124

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

Diff for: examples/http/ntlm-authentication.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var httpProxy = require('http-proxy');
2+
var Agent = require('agentkeepalive');
3+
4+
var agent = new Agent({
5+
maxSockets: 100,
6+
keepAlive: true,
7+
maxFreeSockets: 10,
8+
keepAliveMsecs:1000,
9+
timeout: 60000,
10+
keepAliveTimeout: 30000 // free socket keepalive for 30 seconds
11+
});
12+
13+
var proxy = httpProxy.createProxy({ target: 'http://whatever.com', agent: agent);
14+
15+
//
16+
// Modify headers of the request before it gets sent
17+
// So that we handle the NLTM authentication request
18+
//
19+
proxy.on('proxyRes', function (proxyRes) {
20+
var key = 'www-authenticate';
21+
proxyRes.headers[key] = proxyRes.headers[key] && proxyRes.headers[key].split(',');
22+
});
23+
24+
require('http').createServer(function (req, res) {
25+
proxy.web(req, res);
26+
}).listen(3000);

Diff for: examples/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
"description": "packages required to run the examples",
44
"version": "0.0.0",
55
"dependencies": {
6+
"agentkeepalive": "^2.0.3",
67
"colors": "~0.6.2",
7-
"socket.io": "~0.9.16",
8-
"socket.io-client": "~0.9.16",
98
"connect": "~2.11.0",
9+
"connect-restreamer": "~1.0.0",
1010
"request": "~2.27.0",
11-
"connect-restreamer": "~1.0.0"
11+
"socket.io": "~0.9.16",
12+
"socket.io-client": "~0.9.16"
1213
}
1314
}

0 commit comments

Comments
 (0)