Created
July 13, 2010 02:13
-
-
Save polotek/473356 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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; |
This file contains hidden or 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 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