Espruino's HTTP GET does close the socket right after requesting a page (it tests via content length)... Adding the ability to leave the socket open to request more stuff just seemed like overkill.
Can you not just do:
var data = "";
response.on("data", function(d) {
data+=d;
});
response.on("close", function() {
print("Available = " + data);
});
That's what is shown in all the examples...
But you're saying that if you don't have a data handler, you don't get close called? That could be a bug.
Thing is, even if it worked, doing what you're doing would be a really bad idea - so as not to fill up Espruino's memory if you're not reading data, serial/sockets/etc only buffer ~500 bytes worth of data, and chuck away the rest. You're best off having a data handler, and manually saving away the data as it arrives.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Espruino's HTTP GET does close the socket right after requesting a page (it tests via content length)... Adding the ability to leave the socket open to request more stuff just seemed like overkill.
Can you not just do:
That's what is shown in all the examples...
But you're saying that if you don't have a data handler, you don't get
close
called? That could be a bug.Thing is, even if it worked, doing what you're doing would be a really bad idea - so as not to fill up Espruino's memory if you're not reading data, serial/sockets/etc only buffer ~500 bytes worth of data, and chuck away the rest. You're best off having a data handler, and manually saving away the data as it arrives.