Skip to content

Instantly share code, notes, and snippets.

Created January 3, 2013 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4444380 to your computer and use it in GitHub Desktop.
Save anonymous/4444380 to your computer and use it in GitHub Desktop.
Standard http.request (returns HTTP 200)
var request = require('request');
var http = require('http');
var options = {
hostname: 'es.motionpoint.com',
protocol: 'http:',
port: 80,
path: '/',
method: 'HEAD',
headers: {
'User-Agent': 'Mozilla/5.0+(compatible; Test/2.0; http://www.test.com/)'
}
};
var req = http.request(options, function(res) {
console.log('STATUS: ' + res.statusCode);
//console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
//console.log('BODY: ' + chunk);
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
req.write('data\n');
req.write('data\n');
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment