Skip to content

Instantly share code, notes, and snippets.

@takaheraw
Created January 4, 2013 10:03
Show Gist options
  • Save takaheraw/4451403 to your computer and use it in GitHub Desktop.
Save takaheraw/4451403 to your computer and use it in GitHub Desktop.
var http = require('http');
var options = { host: 'localhost',
port: 1337,
path: '/',
method: 'POST'};
var req = http.request(options, function(res){
var data = '';
res.on('data', function(chunk){
data += chunk;
});
res.on('end', function(){
console.log(data);
});
});
var msg = 'Hello from HTTP Client Request';
req.setHeader('Content-Length', Buffer.byteLength(msg));
req.write(msg);
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment