Skip to content

Instantly share code, notes, and snippets.

@sotonin
Created July 30, 2010 20:51
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 sotonin/501297 to your computer and use it in GitHub Desktop.
Save sotonin/501297 to your computer and use it in GitHub Desktop.
require('utils');
http = require('http');
var http, connection, request;
connection = http.createClient(80, "blog.rubynginx.com");
request = connection.request('GET', "/", {
'Host': 'blog.rubynginx.com',
'User-Agent': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Transfer-Encoding': 'chunked',
'Keep-Alive': '100',
'Connection': 'keep-alive',
'Accept-Language': 'en-us,en;q=0.5',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
});
request.on('response', function (response) {
var output = '';
response.setBodyEncoding("utf8");
response.on("data", function (chunk) {
output += chunk;
});
response.on("complete", function () {
puts("Result = " + output);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment