http.request appears to lack ability to deal with chunking

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
jet11x
Posts: 46
Joined: 29 Dec 2014 21:15

http.request appears to lack ability to deal with chunking

Post by jet11x » 03 Dec 2017 12:21

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.

jet11x
Posts: 46
Joined: 29 Dec 2014 21:15

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

Post by jet11x » 17 Dec 2017 14:57

Any thoughts on this?
I'm now part way into writing code for an intermediate web server.

User avatar
PoltoS
Posts: 4224
Joined: 26 Jan 2011 19:36

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

Post by PoltoS » 17 Dec 2017 17:05

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.

jet11x
Posts: 46
Joined: 29 Dec 2014 21:15

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

Post by jet11x » 17 Dec 2017 19:56

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?


jet11x
Posts: 46
Joined: 29 Dec 2014 21:15

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

Post by jet11x » 20 Dec 2017 09:38

Upgrading to 2.3.6 did the trick. Thanks for the advice.

User avatar
PoltoS
Posts: 4224
Joined: 26 Jan 2011 19:36

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

Post by PoltoS » 23 Dec 2017 01:42

Nice to know. Thanks for the confirmation

Post Reply