Node.js request with socks5 agent truncated response

Ok, i just don't get it.

Let's say i have some node.js application that makes some get/post request. Let's say i also have some socks5 proxy server at localhost:9050.

When i curl the url with the proxy, everything goes well.

But when i try fetching it with http.request, using node-socksified httpAgent to pass requests to socks proxy, response emits "end" event right after receiving first chunk of data.

I've tried another agent implementation with same result. I guess it is somehow connected with node.js dealing with sockets, but i just don't understand what am i doing wrong.

Has someone got same problem?

My code looks something like this:

var options = ...

options.agent = new SocksAgent({
    socks_host : "127.0.0.1",
    socks_port : 9050
});

var req = http.request(options, function(res) {

    res.on("data", function(chunk) {
        console.log(chunk);
    });

    res.on("end", function() {
        console.log("end");
    });
});

req.end();

This issue was caused by socks agent implementations not having implemented support for the new readable streams interface in node 0.10.x.

The two socks v5 client implementations I've written - http-client and https-client support both the old and new interfaces i.e. they work with both node 0.10.x and 0.8.x or lower.