# Http request (open connection)

**URL:** <https://discourse.nodered.org/t/http-request-open-connection/32459>\
**Category:** General\
**Created:** [4 September 2020 20:16 UTC](https://discourse.nodered.org/t/http-request-open-connection/32459 "2020-09-04T20:16:56Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [5 September 2020 20:50 UTC](https://discourse.nodered.org/t/http-request-open-connection/32459/5 "2020-09-05T20:50:04Z")

</div>

Niclas,  
Just guessing based on this:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/5/d5a16cc468d63c90ded79f44d9a31106f434f77c.png)

This is [chunked transfer encoding](https://en.wikipedia.org/wiki/Chunked_transfer_encoding) which is the default encoding. The http-request node will (see [code](https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/nodes/core/network/21-httprequest.js#L337)) wait until all chunks have arrived (via the "request" npm library), and then send the entire response body as an output message. But could it perhaps be that your system keeps sending chunks, so _there is no end of the response_. Which means that the http request node never sends an output message... Could it work like that? I mean that every chunk is in your case in fact a complete piece of data.

If so, the second example [here](https://github.com/request/request) could perhaps be of any help to you. Suppose you rewrite it a bit like this (out of my head, so not tested!):

```auto
const request = require('request')
request(
    { method: 'GET'
    , uri: 'http://192.168.80.121/arx/eventexport?end_date=keep'
    , gzip: true
}
, function (error, response, body) {
      console.log('Most probably the stream has been ended ...')
    }
  )
  .on('data', function(data) {
    // decompressed data as it is received
    console.log('decompressed chunk arrived: ' + data)
    node.send({payload: data});
})

```

The `.on('data ...'` function should be called every time a chunk arrives.

When you use this in a function node, don't forget to add the `request` library to the settings.js file (as described [here](https://nodered.org/docs/user-guide/writing-functions#loading-additional-modules)). See also [this](https://discourse.nodered.org/t/importing-package/9900) discussion...

---

_[View the full topic](https://discourse.nodered.org/t/http-request-open-connection/32459)._
