Skip to content

Instantly share code, notes, and snippets.

@jfhbrook
Created July 30, 2010 21:37
Show Gist options
  • Save jfhbrook/501359 to your computer and use it in GitHub Desktop.
Save jfhbrook/501359 to your computer and use it in GitHub Desktop.
//Does the equivalent of:
// curl -d 'url=http://www.google.com' http://www.ln-s.net/home/api.jsp
var http = require('http');
var querystring = require('querystring');
var client = http.createClient(80, 'www.ln-s.net');
var query = querystring.stringify({url: 'http://www.google.com'});
var request = client.request('POST', '/home/api.jsp?'+query, {host: 'ln-s.net'});
//request.write(query);
request.on('response', function (response) {
//console.log('STATUS: ' + response.statusCode);
//console.log('HEADERS: ' + JSON.stringify(response.headers));
response.on('data', function (chunk) {
console.log('BODY: '+ chunk);
});
});
request.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment