Skip to content

Instantly share code, notes, and snippets.

@sixtus
Created September 16, 2010 16:55
Show Gist options
  • Save sixtus/582747 to your computer and use it in GitHub Desktop.
Save sixtus/582747 to your computer and use it in GitHub Desktop.
var http = require('http');
var client = http.createClient(81, 'localhost');
var request = client.request('GET', '/');
request.end();
request.on('response', function (response) {
console.log('STATUS: ' + response.statusCode);
console.log('HEADERS: ' + JSON.stringify(response.headers));
response.setEncoding('utf8');
response.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
request.on('error', function(error) {
console.log("error");
console.dir(error);
});
console.log("all async baby");
@sixtus
Copy link
Author

sixtus commented Sep 16, 2010

$ node -v
v0.2.1

node trigger.js
all async baby

node.js:63
throw e;
^
Error: ECONNREFUSED, Connection refused
at IOWatcher.callback (net:854:22)
at node.js:769:9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment