Created
April 22, 2011 16:31
-
-
Save ryanbillingsley/936994 to your computer and use it in GitHub Desktop.
Connect Async Basic Auth
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
cluster = require('cluster') | |
http = require('http') | |
connect = require('connect') | |
request = require('request') | |
sys = require('sys') | |
done = (success) -> | |
console.log("FN!" + success) | |
true | |
module.exports = server = connect.createServer( | |
connect.basicAuth( (user, pass, done) -> | |
console.log("Reached callback for BasicAuth") | |
authenticate({ user: user, pass: pass }, done) | |
) | |
connect.router( require('./convore') ) | |
) | |
authenticate = (user,done) -> | |
console.log "Reached Authenticate" | |
console.log("User: "+user.user+" Pass: "+user.pass) | |
request({uri: "https://"+user.user+":"+user.pass+"@convore.com/api/account/verify.json"},(error, response, body) -> | |
if !error && response.statusCode == 200 | |
console.log("Response from request: "+body) | |
done(true) | |
) | |
cluster(server) | |
.set('workers', 4) | |
.use(cluster.debug()) | |
.listen(3000) |
Yes, I forgot to update the gist. The callback fires but the request just hangs. It is never getting a true or false answer
Your globally defined "done" function will not be called, it is overridden by local arguments, and you haven't called "done" in the event of the request failing (this would result in hanging).
ahh that makes a little more sense. thanks for the help.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shouldn't you be calling "fn" as the callback in authenticate?