Added comments and todos linked to the web server

This commit is contained in:
Anatole SCHRAMM 2019-04-15 13:50:54 +02:00
parent 92ce0f0d6e
commit bce884ff57

View File

@ -138,7 +138,7 @@ boolean WEBServerManager::parseQuery(WiFiClient *wifiClient)
_httpParserState = ERROR; _httpParserState = ERROR;
break; break;
case HTTP_RESOURCE_SECTION: case HTTP_RESOURCE_SECTION:
if(_httpRequestData.HRM == POST) if(_httpRequestData.HRM == POST)// Need to be changed, using Content-Length is more appropriate
activeTimeout = longTimeout; activeTimeout = longTimeout;
if(readChar == '?' ) if(readChar == '?' )
@ -170,31 +170,31 @@ boolean WEBServerManager::parseQuery(WiFiClient *wifiClient)
_httpParserState = HTTP_RESOURCE_SECTION; _httpParserState = HTTP_RESOURCE_SECTION;
} }
break; break;
case HTTP_RESOURCE_PARAM_SECTION: case HTTP_RESOURCE_PARAM_SECTION: //index.web?var1=1&var2=2...
if(readChar == ' ') if(readChar == ' ')
{
_httpRequestData.getParams.add(parseKey,new DictionaryHelper::StringEntity(parseValue));
free(parseKey);free(parseValue);
parseKey = NULL;parseValue = NULL;
_httpParserState = HTTP_VER_SECTION;
}
else if( readChar == '=')
isKey = false;
else if(readChar == '&')
{
isKey = true;
_httpRequestData.getParams.add(parseKey, new DictionaryHelper::StringEntity(parseValue));
free(parseKey);free(parseValue);
parseKey = NULL;parseValue = NULL;
}
else
{ {
if(isKey) _httpRequestData.getParams.add(parseKey,new DictionaryHelper::StringEntity(parseValue));
parseKey = addChar(parseKey, readChar); free(parseKey);free(parseValue);
else parseKey = NULL;parseValue = NULL;
parseValue = addChar(parseValue, readChar); _httpParserState = HTTP_VER_SECTION;
} }
break; else if( readChar == '=')
isKey = false;
else if(readChar == '&')
{
isKey = true;
_httpRequestData.getParams.add(parseKey, new DictionaryHelper::StringEntity(parseValue));
free(parseKey);free(parseValue);
parseKey = NULL;parseValue = NULL;
}
else
{
if(isKey)
parseKey = addChar(parseKey, readChar);
else
parseValue = addChar(parseValue, readChar);
}
break;
case HTTP_VER_SECTION: case HTTP_VER_SECTION:
if((readChar >= 48 && readChar <= 57) || readChar == '.') if((readChar >= 48 && readChar <= 57) || readChar == '.')
{ {
@ -211,12 +211,12 @@ boolean WEBServerManager::parseQuery(WiFiClient *wifiClient)
case BODY_SECTION: case BODY_SECTION:
//parseBuffer = addChar(parseBuffer, readChar); //parseBuffer = addChar(parseBuffer, readChar);
break; break;
case PARAMETER_SECTION: case PARAMETER_SECTION: //Here are all the http header params
if(readChar == '\n') if(readChar == '\n')
{ {
_httpParserState = LINE_BREAK; _httpParserState = LINE_BREAK;
} }
break; break;
case IGNORED: case IGNORED:
break; break;
case ERROR: case ERROR: