Finished to add the cookietest api endpoint which purpose is to test the cookie handling feature of the WEBServer
This commit is contained in:
parent
fba428c977
commit
7de29c46a7
@ -670,26 +670,30 @@ boolean cookieTestApi(WEBServer<WEBClient> *ws, WEBServer<WEBClient>::HttpReques
|
||||
if(HRD.getParams("set") != NULL)
|
||||
{
|
||||
uint8_t cookieCount(HRD.getParams.count() - 1);
|
||||
Serial.printf("Cookies to be set/unset : %u\n", cookieCount);
|
||||
|
||||
for(uint8_t i(0); i < HRD.getParams.count(); i++)
|
||||
{
|
||||
if(strcmp(HRD.getParams.getParameter(i), "set") != 0)
|
||||
{
|
||||
if(!strlen(HRD.getParams.getAt(i)->getString())) //We ask to remove the cookie
|
||||
{
|
||||
Serial.printf("Unsetting cookie %s->%s\n", HRD.getParams.getParameter(i), HRD.getParams.getAt(i)->getString());
|
||||
ws->addCookies(HRD.getParams.getParameter(i), HRD.getParams.getAt(i)->getString(), 0);
|
||||
}
|
||||
else //We add the cookie
|
||||
{
|
||||
Serial.printf("Setting cookie %s->%s\n", HRD.getParams.getParameter(i), HRD.getParams.getAt(i)->getString());
|
||||
ws->addCookies(HRD.getParams.getParameter(i), HRD.getParams.getAt(i)->getString(), 3600);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ws->sendHTTPResponse(wc, HttpConstants::httpMIMETypeToString(HttpConstants::TEXT_PLAIN)); //We dont know the content length
|
||||
wc->printf("Setting/Unsetting %u cookies : \n", cookieCount);
|
||||
for(uint8_t i(0); i < HRD.getParams.count(); i++)
|
||||
{
|
||||
if(strcmp(HRD.getParams.getParameter(i), "set") != 0)
|
||||
{
|
||||
if(!strlen(HRD.getParams.getAt(i)->getString())) //We ask to remove the cookie
|
||||
wc->printf("Unsetting cookie %s->%s\n", HRD.getParams.getParameter(i), HRD.getParams.getAt(i)->getString());
|
||||
else //We add the cookie
|
||||
wc->printf("Setting cookie %s->%s\n", HRD.getParams.getParameter(i), HRD.getParams.getAt(i)->getString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else //We print the setted cookies
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user