Page 1 of 1

http.request appears to lack ability to deal with chunking

Posted: 03 Dec 2017 12:21
by jet11x
I'm trying to use http.request to get status information from an alarm system.
After some fiddling I managed to get the first part of the response, but not the details I required.
Doing the same query from a small node.js application I believe the problem is that the data is coming back in chunks and I'm only getting the first one back using http.request

I using the asynch mode in the hope it would do repeated calls to responses, but both method success and complete only get called once.

At this stage only way to solve this that I can see is to setup an intermediate web-server that extracts the information required and makes available for http.request in z-wave.me module or another web server that get data from alarm and then call in to the JS functions of z-wave.me. Both call for complexity of another web server which isn't ideal.
I'm also going to see if I can use the socket API to do my own http client implementation.

I can't find the source for http.request anywhere to investigate - I assume this is part of the C implementation which isn't made public.

Appreciate any workarounds or fixes you can suggest.

Re: http.request appears to lack ability to deal with chunking

Posted: 17 Dec 2017 14:57
by jet11x
Any thoughts on this?
I'm now part way into writing code for an intermediate web server.

Re: http.request appears to lack ability to deal with chunking

Posted: 17 Dec 2017 17:05
by PoltoS
Do you have an example of such server? Some public request.

In v.2.3.6 we have added the ability to decode the answer (added CURLOPT_HTTP_CONTENT_DECODING). If this do not help to decode chunked, we can fix that.

Re: http.request appears to lack ability to deal with chunking

Posted: 17 Dec 2017 19:56
by jet11x
I don't have a public example. But here's some more information:
- Wikipedia article on chunking in http 1.1. https://en.wikipedia.org/wiki/Chunked_transfer_encoding
- Example using node js and http.request with chunking, search for chunk on https://nodejs.org/en/docs/guides/anato ... ansaction/

I'll see about moving on to 2.3.6 in the not to distant future. Is there more information on CURLOPT_HTTP_CONTENT_DECODING?

Re: http.request appears to lack ability to deal with chunking

Posted: 17 Dec 2017 23:45
by PoltoS

Re: http.request appears to lack ability to deal with chunking

Posted: 20 Dec 2017 09:38
by jet11x
Upgrading to 2.3.6 did the trick. Thanks for the advice.

Re: http.request appears to lack ability to deal with chunking

Posted: 23 Dec 2017 01:42
by PoltoS
Nice to know. Thanks for the confirmation