You are reading a single comment by @dave_irvine and its replies. Click here to read the full conversation.
  • Following code sample fails:

    var wifi = require("EspruinoWiFi");
    var http = require('http');
    
    wifi.connect('yourAP', { password: 'yourPass' }, function(err) {
      if (err) { throw err; }
      
      wifi.getIP(function (err, data) {
        if (err) { throw err; }
    
        console.log(data);
        
        var options = {
          host: 'espruino.com',
          port: 80,
          path: '/',
          method: 'HEAD',
        };
    
        console.log('about to http request');
        http.request(options, function(res) {
          console.log('request cb');
          res.on('data', function(data) {
            console.log("HTTP> "+data);
          });
    
          res.on('close', function(data) {
            console.log(data);
            console.log("Connection closed");
          });
    
          res.on('error', function(err) {
            console.log(err);
          });
        }).end();
      });
    });
    
    

    Produces only:

    about to http request
    request cb
    false
    Connection closed

    Change it to a GET request and you get:

    about to http request
    request cb
    HTTP> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    >


    Moved Permanently


    The docu
    HTTP> ment has moved here.




    s>Apache/2.4.18 (Ubuntu) Server at espruino.com Port 80
    tml>
    false
    Connection closed

    but I want the HTTP headers not the content.

About

Avatar for dave_irvine @dave_irvine started