Hello,
I am experimenting http.Agent() for using a http request with socks
protocol support.
Before to implement a socks protocol support i was trying http.Agent() with
basic socket for debuging and understanding the idea behing http.Agent.
My question is following the code bellow, is it the right way to work with
http.Agent() and a custom created socket by creating his proper
http.Agent().createConnection function?
Should i care about something else?
var net = require('net');
var http = require('http');
options = {
host : 'www.google.com',
port: 80,
path: '/index.html',
method: 'GET'
};
//The interesting part
var a = new http.Agent();
a.createConnection = function(){
return ((new net.Socket()).connect(options.port, options.host));
};
options.agent = a;
//Standard http request
var req = http.request(options, function(res){
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function(chunk) {
console.log('BODY: ' + chunk);
});
});
req.on('error', function(e){
console.log("Got error " + e.message);
});
req.end();
Thanks you for reading.
regards,
Sofiane Akermoun
[email protected]
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.