Created
January 3, 2013 15:42
-
-
Save anonymous/4444380 to your computer and use it in GitHub Desktop.
Standard http.request (returns HTTP 200)
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
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