Closed Sparatutto closed 2 years ago
arg("plain")
is the body. You can safely ignore it. It has been added to help solving a bug.
The webserver logic has been rewritten (#5636) but is still wip and in the need for testing.
Hi dav, thanks for the feedback. I see you are changing a lot and maybe for me at the moment is better to stay with core 2.4.2. By the way, I cannot ignore it, I have checks on the number and the names of the argument transferred to decide which server page must be loaded. I could remove the check on the number and check only the names. But unfortunately it seems to be not the only issue.
Another part of my code is transferring an argument composed by different part separated by a semicolon ";". In some manner any ";" is recognized as a different argument.
` bool manageClientUpdate(int module, int tmpZone, int btnCommand)
{
extern struct zone tmpServerZone[NUM_OF_ZONES];
char tmpBuffer[100];
int tmpPwd = random(2, 220); // 220 is the maximum because the password can be 30char max
sprintf(tmpBuffer, "&btnCmd=%01d&zcfg=%01d;%02d;%02d;%04d;%04d;%04d;%04d;%03d;%s;-", btnCommand, tmpZone, tmpServerZone[tmpZone].nonc, tmpServerZone[tmpZone].instantOnOff, tmpServerZone[tmpZone].timeOn_1 & (~USED_TODAY), tmpServerZone[tmpZone].timeOff_1 & (~USED_TODAY), tmpServerZone[tmpZone].timeOn_2 & (~USED_TODAY), tmpServerZone[tmpZone].timeOff_2 & (~USED_TODAY),tmpServerZone[tmpZone].monTimer,tmpServerZone[tmpZone].zoneName);
Serial.println("Module:" +(String)module + tmpBuffer);
String webPage = "POST /cccc?"; //webPage = "POST /cccc?azyx=1&d=1&pippo=bene&pluto=male&paperino=1234 HTTP/1.1\r\n";
webPage+= "mid=" + (String)serverModules[module].moduleId + "&tmpp=100" + (String)tmpBuffer;
webPage += " HTTP/1.1\r\nHost: " +(String)serverModules[module].moduleIP + "\r\nCookie: TYPE=ttt;\r\nConnection: close\r\n\r\n";
client.print(webPage);
//Serial.print(webPage);
unsigned long timeout = millis();
while (client.available() == 0)
{
if (millis() - timeout > 5000)
{
Serial.println(">>> Client Timeout !");
client.stop();
return false;
}
}
// Read all the lines of the reply from server and print them to Serial
String connResult =" ";
while(client.available())
{
connResult+= client.readStringUntil('\n');
}
client.stop();
//Serial.print(connResult);
if(connResult.indexOf("HTTP/1.1 200 OK")>=0)
{
Serial.println("\r\nClient updated");
return true;
}
else
Serial.println("Client update failed");
//Serial.println("Server to client closed");
return false;
}`
SO checking the returned arg I have one for any ";" and it is not correct. I hope the comment can help you.
@Sparatutto I don't understand why you can't just ignore plain. In your original post, please explain the expected output vs. the output that you get. Also, add hints to the code explaining why you can't ignore plain.
Hi Devyte, yes for sure I can ignore the plain argument but it means change many of the written code so far. In the problem description you can see the picture of the current output. The expected output with the old core is ARG 0 to ARG 2 , ARG 3 is what I do not expect.
Regarding the code, I have conditional code based on the number of arguments and the content, maybe it is not the best way but it is what I have. Here below an example.
// if the read/detail button is pressed the server send the information of the selected module
if((server.args() == 1) && (server.hasArg("Req")))
{
module=server.arg("Req").toInt();
logTime();
//Serial.printf("superclient: module %02d @%s:%s STATUS REQUEST ", module, serverModules[module].moduleIP,serverModules[module].modulePort);
Serial.printf("superclient: module %02d @%s:%d STATUS REQUEST ", module, serverModules[module].moduleIP,serverModules[module].modulePort);
receivedTime = manageServerToClient(module); //manageServerToClient(module, &zoneStatusClient);
//Serial.println("Time received from module:" + (String)receivedTime);
if(receivedTime>=0)
{
addAns = true;
}
}
// if the send button of a zone is pressed the corresponding zone of the selected module is updated
if((server.args() == 10) && (server.hasArg("Name")))
{
module=server.arg("Name").toInt();
tmpZone = server.arg("zone").toInt();
Serial.println("The module required is:" + server.arg("Name") + " ZOne: " + server.arg("zon") + " - " + (String)tmpZone);
tmpServerZone[tmpZone].instantOnOff = server.arg("in").toInt();
tmpServerZone[tmpZone].nonc = server.arg("mo").toInt();
if(tmpServerZone[tmpZone].instantOnOff != ZONE_INPUT)
{
tmpServerZone[tmpZone].timeOn_1=server.arg("TB").substring(0,server.arg("TB").indexOf(":")).toInt()*MINUT_CONVER+server.arg("TB").substring(server.arg("TB").indexOf(":")+1).toInt();
tmpServerZone[tmpZone].timeOff_1= server.arg("TE").substring(0,server.arg("TE").indexOf(":")).toInt()*MINUT_CONVER + server.arg("TE").substring(server.arg("TE").indexOf(":")+1).toInt();
tmpServerZone[tmpZone].timeOn_2 = ....
...
}
...
// Send the initial part of the HTML web page
server.send(200, "text/html", "");
server.sendContent(webPage);
//this occours only at the first login or any time the list button is pressed
if(server.args() == 0)
{
...
}
thx.
@Sparatutto #6768 addresses your concern about arg("plain")
which shouldn't be counted in the argument list.
About ;
I'm afraid you'll have to escape it with %3B
because it can be used as argument separator
These fixes may be available in core-2.6.1.
Hello all, @d-a-v It seems you have fixed the issue in #6768 but i still see the issue: plain counted as argument. I'm using board lib 3.0.2. Am I doing some mistake ? Commented already in #6768 in August. Thanks for the feedback.
Commented already in #6768 in August.
You should have opened a new issue back then so it may not have been forgotten.
Am I doing some mistake ?
The first mistake I can see is to not open a new issue to track that down.
If I can't answer now, this is going to be forgotten. Please open a new issue.
Reopening
Commented already in #6768 in August.
You should have opened a new issue back then so it may not have been forgotten.
Am I doing some mistake ?
~The first mistake I can see is to not open a new issue to track that down.~
~If I can't answer now, this is going to be forgotten. Please open a new issue.~
@d-a-v thanks. and sorry for my mistake
Basic Infos
[X] I have read the documentation at readthedocs and the issue is not addressed there.
[X] I have searched the issue tracker for a similar issue.
Platform
Settings in IDE
attached picture
Problem Description
I have updated the Arduino IDE to 1.8.9 and the core to 2.5.2 using the board manager ( not the git). Compiling my project that was working and running very stable with the core 2.4.x now I'm facing some issue related to the number of argument returned by the http communication. In particular I see an extra argument named plain received by the AP, that was not present and transferred before. So expected number of arguments (correct in the last compile with 2.4.x) in this example was 3, instead with the new core I get 4.
And this is making me crazy because I have many pages and not sure what is happening.
Maybe it is a stupid error of mine but having it in conjunction to the switch to this new core, I try to write you for a check. Thanks!
MCVE Sketch
Debug Messages