Last active
August 29, 2015 14:17
-
-
Save bobpace/8bb1843363f654f74953 to your computer and use it in GitHub Desktop.
Koa.js curl proxy with ntlm authentication
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
var spawn = require('child_process').spawn; | |
var eventStream = require('./event-stream'); | |
var compose = require('koa-compose'); | |
//get username / password from somewhere | |
var username = ...; | |
var password = ...; | |
var credential = username + ':' + password; | |
//8 hour timeout | |
var timeout = 8 * 60 * 60; | |
module.exports = function curlProxy(url) { | |
return compose([ | |
eventStream(), | |
function *() { | |
var child = spawn('curl', ['--ntlm', '-u', credential, '-N', '-m', timeout.toString(), url], { | |
//ignore stdio and stderr so they don't fill up and cause stdout to pause | |
stdio: ['ignore', 'pipe', 'ignore'] | |
}); | |
this.body = child.stdout; | |
} | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment