Espruino/tests/test_http.js
Gordon Williams 7bbfb6a0a8 Add HttpServer.close
Ensure that Linux command-line tests keep running if there's something to do
2014-03-06 12:20:23 +00:00

25 lines
616 B
JavaScript

// HTTP server and client test
var result = 0;
var http = require("http");
var server = http.createServer(function (req, res) {
console.log("Connected " + JSON.stringify(req));
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('42');
res.end();
});
server.listen(8080);
http.get("http://localhost:8080/foo.html", function(res) {
console.log("Got response: " + JSON.stringify(res));
res.on('data', function(data) {
console.log(">" + data);
result = data=="42";
server.close();
});
});//.on('error', function(e) {
// console.log("Got error: " + e.message);
//});*/