You are reading a single comment by @akot and its replies. Click here to read the full conversation.
  • Hello!

    I connect to some API that continuously sends events via a chunked transfer ("Transfer-Encoding": "chunked"). My goal is to terminate the request after receiving a specific event.

    require("http").get("https://someapi.comĀ­", function(res) {
        res.on('data', function(data) {
            if (data == "someEvent") {
                // terminate the request
            } 
        });
        res.on('close', function() { print("closed"); });
    });
    

    How can I achieve it? I know that get returns a httpCRq object, but it doesn't have abort() or destroy() methods. If I keep the connection open, it consumes a lot of memory, so I need to close it.

About

Avatar for akot @akot started