I'm not sure how you can do this with Node, but the general idea would be to send an HTTP HEAD request to the URL you are interested in.
HEAD
requests a response identical to the one corresponding to the GET request, but without the response body. This is useful for retrieving the meta-information written in the response headers without transferring all the content.
Something like this, based on this question :
var cli = require('cli'); var http = require('http'); var url = require('url'); cli.parse(); cli.main(function(args, opts) { this.debug(args[0]); var siteUrl = url.parse(args[0]); var site = http.createClient(80, siteUrl.host); console.log(siteUrl); var request = site.request('HEAD', siteUrl.pathname, {'host' : siteUrl.host}) request.end(); request.on('response', function(response) { response.setEncoding('utf8'); console.log('STATUS: ' + response.statusCode); response.on('data', function(chunk) { console.log("DATA: " + chunk); }); }); });
Matt Ball May 7 '11 at 17:43 2011-05-07 17:43
source share