Espruino/tests/test072.js
Gordon Williams f3d6e0bc83 First commit
2013-09-26 14:39:04 +01:00

24 lines
628 B
JavaScript

// HTTP server and client test
var result = 0;
var timeout = setTimeout("print('done');", 10000000);
http.createServer(function (req, res) {
console.log("Connected " + JSON.stringify(req));
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('42');
res.end();
}).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";
clearTimeout(timeout);
});
});//.on('error', function(e) {
// console.log("Got error: " + e.message);
//});*/