From bce884ff575051321d7d64f185e7be11912203a5 Mon Sep 17 00:00:00 2001 From: Anatole SCHRAMM Date: Mon, 15 Apr 2019 13:50:54 +0200 Subject: [PATCH] Added comments and todos linked to the web server --- src/app/WEBServerManager.cpp | 60 ++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/app/WEBServerManager.cpp b/src/app/WEBServerManager.cpp index c6ff148..2f37092 100644 --- a/src/app/WEBServerManager.cpp +++ b/src/app/WEBServerManager.cpp @@ -138,7 +138,7 @@ boolean WEBServerManager::parseQuery(WiFiClient *wifiClient) _httpParserState = ERROR; break; case HTTP_RESOURCE_SECTION: - if(_httpRequestData.HRM == POST) + if(_httpRequestData.HRM == POST)// Need to be changed, using Content-Length is more appropriate activeTimeout = longTimeout; if(readChar == '?' ) @@ -170,31 +170,31 @@ boolean WEBServerManager::parseQuery(WiFiClient *wifiClient) _httpParserState = HTTP_RESOURCE_SECTION; } break; - case HTTP_RESOURCE_PARAM_SECTION: - 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 + case HTTP_RESOURCE_PARAM_SECTION: //index.web?var1=1&var2=2... + if(readChar == ' ') { - if(isKey) - parseKey = addChar(parseKey, readChar); - else - parseValue = addChar(parseValue, readChar); + _httpRequestData.getParams.add(parseKey,new DictionaryHelper::StringEntity(parseValue)); + free(parseKey);free(parseValue); + parseKey = NULL;parseValue = NULL; + _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: if((readChar >= 48 && readChar <= 57) || readChar == '.') { @@ -211,12 +211,12 @@ boolean WEBServerManager::parseQuery(WiFiClient *wifiClient) case BODY_SECTION: //parseBuffer = addChar(parseBuffer, readChar); break; - case PARAMETER_SECTION: - if(readChar == '\n') - { - _httpParserState = LINE_BREAK; - } - break; + case PARAMETER_SECTION: //Here are all the http header params + if(readChar == '\n') + { + _httpParserState = LINE_BREAK; + } + break; case IGNORED: break; case ERROR: