You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Espruino won't redirect itself, but it's dead easy to add code for this. Try:

    function getRedirect(url, callback) {
      require("http").get(url, function(res) {
        var contents = "";
        res.on('data', function(data) { contents += data; });
        res.on('close', function() { 
          if (res.statusCode==301 || res.statusCode==302) {
            console.log("Redirecting to "+res.headers.Location); 
            contents = ""; // free memory
            getRedirect(res.headers.Location, callback);
          } else
            callback(contents);
        });
      });
    }
    
    // espruino.com redirects to http://www.espruino.com
    getRedirect("http://espruino.com", function(contents) { 
      console.log("Got:"+contents); 
    });
    

    Only thing I'd say is Espruino doesn't do HTTPS at the moment - the resources needed to handle SSL are really high for a microcontroller, and I haven't had time to try and shoehorn it in yet. It might be that the Google app redirects to an HTTPS URL, and won't accept non-secure connections. Not sure about that though.

About

Avatar for Gordon @Gordon started