I tried piping but was having issues: The following code throws an "Cannot
call method 'on' of undefined" error at the last line.
proxy.on('request', function(req, res){
var uri = url.parse(req.url);
var httpMessage = req.method + ' ' + uri.path + ' HTTP/'+ req.httpVersion +
'\r\n';
for(var header in req.headers){
httpMessage += header + ': ' + req.headers[header] + '\r\n';
}
httpMessage += '\r\n';
var client = net.connect(uri.port || 80, uri.hostname);
client.write(httpMessage);
req.connection.pipe(client);
client.pipe(res.connection);
});
When I change that last line to client.pipe(req.connection); , it works,
but for some requests I get multiple warnings:
"(node) warning: possible EventEmitter memory leak detected. 11 listeners
added. Use emitter.setMaxListeners() to increase limit."
at the last two lines. I think I'm piping correctly in the first scenario,
but I'm not sure what the source of errors/warnings is.
Regards,
Alex
On Friday, August 3, 2012 4:37:48 AM UTC-4, Diogo Resende wrote:
>
> I'm not sure why you don't use .pipe().. you don't need to buffer all the
> request before sending it. The headers should have a content-length so your
> endpoint will know about it. Just send the data directly to the other end
> instead of buffering.
>
> --
> Diogo Resende
>
>
--
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