http.onrequest POST strangeness today

I'm not sure what's happened but as of around mid-day lots of things stopped working for me that had been working OK for years: Certain http POST requests to my imp agent are being received as method="GET"!

These requests are all variously sourced from my home network (e.g. Raspberry Pi, ESP8266 and manual testing using the Postman app) The only external POST requests I have are coming in from Amazon servers - and they are received OK as method="POST". This is really puzzling me now. I very much doubt that it's a problem with the imp servers but I'm stuck for ideas on how to go about figuring out what's happening.

Comments

  • edited February 28
    Extra info: Setting up a second imp at home sending http.post to the first imp does work, resulting in receipt of the correct method. So POSTs coming from outside my home network (e.g Amazon, Imp) are just fine.

    This second imp also exhibits the same odd receive behaviour with http.onrequest. Using Postman I can quickly switch between different methods and they all come through (PUT, PATCH, DELETE etc.) except for POST which continues to come in as GET. crazy.
  • Is it just your agents seeing this weirdness? Can you POST to other HTTP sites? I assume so, otherwise you wouldn't have posted to the forums, but...
  • Only agents. If I direct the exact same requests to http://requestb.in (say, using Postman) they show up no problem.
  • Steps to reproduce behaviour I'm getting: add some noddy Agent code...

    //RESPOND TO INCOMING HTTP REQUESTS
    http.onrequest(function(request,response){
    server.log("Method: "+request.method); //show method
    try
    {
    local json=http.jsondecode(request.body);
    server.log("Message: "+json.message);
    }catch(error){server.log(error)}
    response.send(200, "OK");
    });


    Google-up "Chrome Postman" and launch the app (no signup required if you follow the link at the bottom)

    Enter an agent URL, select body, raw and enter message, dropdown to JSON (application/json) then Send - switching between POST, PUT etc.

    image

    PUT and every method other than GET should work, except that POST doesn't. You'll see it magically arrive at the Agent as a GET, without a JSON message.

    To reiterate, I'm also seeing this with node.mcu Lua (ESP8266) HTTP calls. though I often use Postman to test out web APIs and it should be easy for anyone to replicate the problem.
    Screenshot 2017-03-01 10.24.45.png
    1363 x 1021 - 91K
  • OK, so what's apparently changed is HTTPS access is now required. Up until now the Agents were taking non-secure post but it looks like that changed yesterday. Postman works if I prefix agent.electricimp.com with https:// but my ESP8266 devices are going to be a little harder to resolve!
  • We're still investigating, but it looks like we inadvertently pushed a change that redirects HTTP to HTTPS. That works transparently with most clients for GET, etc., but maybe not so much for POST.

    We'll revert that in the next few minutes.

    We recommend using HTTPS in future.
  • edited March 1
    This should be fixed now.
  • Great response, team. Very much appreciated although I've already taken the opportunity to re-code my applications to use https as you recommend :\">
Sign In or Register to comment.