Sending additional http headers using http.get()

Posted on
  • Hello everyone,

    is it possible to send additional HTTP header attributes using Espruino's http.get() function or do I have to write my own http class for that?

    I need it for example for using HTTP Basic Authentication.

    Best,

    Tobias

  • Well, you should be able to specify them as an option to get, but if you're going that far it might be better to be more explicit:

       var options = {
          host: 'server.name.com',
          port: '80',
          path:'/my/path.php',
          method:'GET',
          headers: { "A":"B" }
        };
        var req = require("http").request(options, function(res)  { ... });
    

    The Xively example does this, but with POST.

  • ...authentication in clear? I'm not aware of that Espruino supports https...

  • No, it doesn't support HTTPS - but that doesn't stop you from doing HTTP basic authentication. It's just not very secure if someone could look at the web traffic

  • ...I guess that the code for HTTPS just does not fit into the available space... and even if it would fit, it would hamper the intended work of the core processor which should not be tied up with doing encryption/decryption.

    Therefore, 'cheap'/simple comm-devices just are not a solution. For Wifi behind a DMZ with target nodes behind the DMZ, CC3000 or any other WPA2 security supporting system would though be good enough. But in such a case, why would that need authentication, because eaves dropping would have to be on the wire. (For most secure/safe communication, systems behind the DMZ communicate also over HTTPs.)

  • Something like the ESP8266 WiFi module could possibly handle SSL/HTTPS internally. There seem to be sources in the SDK for it, so hopefully it'll only be a matter of time before there is an 'AT command' firmware update that supports it - and when that happens it'll be trivial to support in Espruino.

    I get your point about authentication - however something like basic auth is trivial to implement, and would help to stop casual (or accidental) problems.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Sending additional http headers using http.get()

Posted by Avatar for net-tobi @net-tobi

Actions