Created
March 21, 2012 19:53
-
-
Save ebot/2152056 to your computer and use it in GitHub Desktop.
Nodejs script that is the simplest possible way to log into a remote server with basic authentication.
This file contains hidden or 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
http = require("http") | |
uname = "uname" | |
pword = "pword" | |
options = | |
host: "server_name_or_ip" | |
port: 80 | |
path: "/path/to/page.aspx" | |
headers: | |
Authorization: "Basic " + new Buffer(uname + ":" + pword).toString("base64") | |
request = http.get(options, (res) -> | |
body = "" | |
res.on "data", (data) -> | |
body += data | |
res.on "end", -> | |
console.log body | |
res.on "error", (e) -> | |
console.log "Got error: " + e.message | |
) |
This file contains hidden or 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 http = require('http'); | |
var uname = 'uname'; | |
var pword = 'pword'; | |
var options = { | |
host: 'server_name_or_ip', | |
port: 80, | |
path: '/path/to/page.aspx', | |
headers: { | |
'Authorization': 'Basic ' + new Buffer(uname + ':' + pword).toString('base64') | |
} | |
}; | |
request = http.get(options, function(res){ | |
var body = ""; | |
res.on('data', function(data) { | |
body += data; | |
}); | |
res.on('end', function() { | |
console.log(body); | |
}) | |
res.on('error', function(e) { | |
console.log("Got error: " + e.message); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment