• Try:

      var options = {
        host: 'example.com',
        path: '/',
        method: 'GET'
      };
      http.request(options, callback).end();
    

    I think the issue is that the path isn't specified, so it's asking the server for a page called "", which it complains about.

    If you used var options = url.parse('http://example.com') it'd neatly populate everything you need for you.

    Why do I get different responses when using 'get' and 'GET'?

    Because that string is being sent to the HTTP server as-is, and the HTTP server is case-sensitive. Espruino doesn't convert it to upper-case for you just in case you're trying to do something non-standard with an HTTP server.

    I'll add something to the docs on it.

About

Avatar for Gordon @Gordon started