diff options
author | przemyslawpluta <przemekpluta@hotmail.com> | 2014-09-27 16:00:04 +0100 |
---|---|---|
committer | przemyslawpluta <przemekpluta@hotmail.com> | 2014-09-27 16:00:04 +0100 |
commit | 8c67cd34fbc3501c9bd6b197b1e8b6ecf5c14d61 (patch) | |
tree | 87f17c519943c3a3ccb0cf19bff21a31b681ca2d /lib/login.js | |
parent | 3933a61a27a8d19272322d8f18b8111d70740993 (diff) | |
download | mongo-edu-8c67cd34fbc3501c9bd6b197b1e8b6ecf5c14d61.zip |
update
add proxy test
cleanup
version bump
Diffstat (limited to 'lib/login.js')
-rw-r--r-- | lib/login.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/login.js b/lib/login.js index d7f3fdf..01ecd6d 100644 --- a/lib/login.js +++ b/lib/login.js @@ -193,5 +193,20 @@ module.exports = { callback(new Error(res.statusCode)); }); + }, + + checkProxy: function checkProxy(target, callback) { + request(target, function get(err, response) { + if (err !== null) { return callback(err); } + if (response.statusCode === 200) { + var stack = ''; + if (response.headers.server) { stack = 'Proxy Server: '.bold + response.headers.server.cyan + ' '; } + if (response.headers['x-powered-by']) { stack += 'Powered-by: '.bold + response.headers['x-powered-by'].cyan + ' '; } + stack.trim(); + if (stack === '') { stack = target; } + return callback(null, stack); + } + callback(new Error('Server Response: '.red + response.statusCode)); + }); } }; |