Last active
October 12, 2018 21:31
-
-
Save devyte/0e51bc55557af5a3b56bfb040515db08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct storeArgHandler | |
{ | |
void operator(RequestArgument &arg, const String & data, int pos, int key_end_pos) //args are local vars | |
{ | |
arg.key = urlDecode(data.substring(pos, key_end_pos)); | |
if ( (equal_index != -1) && ( (equal_index < next_index - 1) || (next_index == -1)) ) | |
arg.value = urlDecode(data.substring(equal_index + 1, next_index - 1)); | |
#ifdef DEBUG_ESP_HTTP_SERVER #ifdef DEBUG_ESP_HTTP_SERVER | |
DEBUG_OUTPUT.print("arg "); DEBUG_OUTPUT.print("arg "); | |
DEBUG_OUTPUT.print(iarg); DEBUG_OUTPUT.print(arg_total); | |
DEBUG_OUTPUT.print(" key: "); DEBUG_OUTPUT.print(" key: "); | |
DEBUG_OUTPUT.print(arg.key); DEBUG_OUTPUT.print(arg.key); | |
DEBUG_OUTPUT.print(" value: "); DEBUG_OUTPUT.print(" value: "); | |
DEBUG_OUTPUT.println(arg.value); DEBUG_OUTPUT.println(arg.value); | |
#endif | |
} | |
}; | |
struct nullArgHandler | |
{ | |
void operator(RequestArgument &arg, const String & data, int pos, int key_end_pos) {} //args are local vars | |
}; | |
int ESP8266WebServer::_parseArgumentsCore(const String& data, func) | |
{ | |
size_t pos = 0; | |
int arg_total = 0; | |
... | |
while(true) | |
{ | |
... | |
func(_currentArgs[arg_total], data, pos, key_end_pos, equal_index, next_index); | |
... | |
} | |
... | |
return arg_total; | |
} | |
int ESP8266WebServer::_parseArguments(const String& data) | |
{ | |
int counted = _parseArgumentsCore(data, nullArgHandler()); | |
if(_currentArgs) | |
{ | |
delete[] _currentArgs; | |
_currentArgs = 0; | |
_currentArgs = new RequestArgument[(_currentArgCount = counted) + 1]; | |
} | |
_parseArgumentsCore(data, storeArgHandler()); | |
_currentArgCount = counted; | |
return counted; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment