Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By brenzo
#66318 I'm sure there's a really simple answer here and maybe I'm Googling for the wrong thing but I can't for the life of me figure out how to read data from the client when I'm the webserver. Just how to handle posts to specific URL's. For example...

Code: Select all    ESP8266WebServer server(80);
    server.on("/config", handle_config);

//////

    void handle_config(){
        //I want to intercept a json telegram from my client here
        //I will store it in a buffer and pass it to a JSON parsing function
    }
Last edited by brenzo on Thu May 25, 2017 1:17 pm, edited 1 time in total.
User avatar
By Pablo2048
#66323 IMHO this can not be done in standard Arduino Core library. You have to use AsyncWebserver and hook receiving callback like this
Code: Select all  www.on("/saverulesxml", HTTP_POST, www_XMLrules, NULL, www_bodyXMLrules);

then www_bodyXMLrules (change the name :-) ) is invoked periodically as data arrive to webserver...

EDIT!!! - Maybe i'm wrong and You can handle this even in standard core - try to study HTTPUpload object... (anyway i'm using Async - it's faster, supports multiple connections and websockets in one port...)
Last edited by Pablo2048 on Thu May 25, 2017 1:41 pm, edited 1 time in total.
User avatar
By brenzo
#66324
martinayotte wrote:The server receive the post as arguments, for example :
Code: Select all  if (server.args() > 0 ) {
    if (server.hasArg("password")) {
      pw = webserver.arg("password");
      Serial.println(pw);
    }


Are these like the headers in a POST?
Pablo2048 wrote:IMHO this can not be done in standard Arduino Core library. You have to use AsyncWebserver and hook receiving callback like this
Code: Select all  www.on("/saverulesxml", HTTP_POST, www_XMLrules, NULL, www_bodyXMLrules);

then www_bodyXMLrules (change the name :-) ) is invoked periodically as data arrive to webserver...


That seems surprising, I can't imagine it's an exceptionally uncommon thing to want to do. :P Even if I could just get all of the raw data sent by the client I'm happy to parse it myself. Any way to just get EVERYTHING in the POST?