Skip to content

Instantly share code, notes, and snippets.

@polotek
Created July 13, 2010 02:13
Show Gist options
  • Save polotek/473356 to your computer and use it in GitHub Desktop.
Save polotek/473356 to your computer and use it in GitHub Desktop.
var sys = require('sys');
var Client = require('http').Client;
function MyClient() {
Client.call(this);
this.testProp = 'testprop';
};
sys.inherits(MyClient, Client);
MyClient.prototype.tester = function() { sys.puts(this.testProp); };
exports.MyClient = MyClient;
var sys = require('sys');
var http = require("myhttp");
var client = new http.MyClient();
client.port = 80;
client.host = 'www.google.com';
client.https = undefined;
client.credentials = undefined;
var request = client.request('GET', '/'
, {'host': 'www.google.com'});
request.addListener('response', function (response) {
console.log('STATUS: ' + response.statusCode);
console.log('HEADERS: ' + JSON.stringify(response.headers));
response.setEncoding('utf8');
response.addListener('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
request.end();
client.tester();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment