-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate HttpParams class and fix escaping
WebHelpers/escape * bugfix: encoding of space as '+' added * uri_escape(const char*, int) rewritten without using heap * add uri_unescape_inplace(char*, int) * bugfix: output buffer must account for nul terminator in uri_unescape_inplace(String&) structures.h * Move HttpParams definition into separate module UrlencodedOutputStream * Remove (duplicate) definition of HttpParams * Move output code into HttpParams::printTo() method
- Loading branch information
Showing
8 changed files
with
141 additions
and
32 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/**** | ||
* Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. | ||
* Created 2015 by Skurydin Alexey | ||
* http://github.com/SmingHub/Sming | ||
* All files of the Sming Core are provided under the LGPL v3 license. | ||
* | ||
* @author: 2018 - Mikee47 <[email protected]> | ||
* | ||
****/ | ||
|
||
#include "HttpParams.h" | ||
#include "../Services/WebHelpers/escape.h" | ||
#include "Print.h" | ||
|
||
size_t HttpParams::printTo(Print& p) const | ||
{ | ||
size_t charsPrinted = 0; | ||
for(unsigned i = 0; i < count(); i++) { | ||
if(i > 0) | ||
charsPrinted += p.print('&'); | ||
charsPrinted += p.print(uri_escape(keyAt(i))); | ||
charsPrinted += p.print('='); | ||
charsPrinted += p.print(uri_escape(valueAt(i))); | ||
} | ||
|
||
return charsPrinted; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/**** | ||
* Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. | ||
* Created 2015 by Skurydin Alexey | ||
* http://github.com/SmingHub/Sming | ||
* All files of the Sming Core are provided under the LGPL v3 license. | ||
* | ||
* @author: 2018 - Mikee47 <[email protected]> | ||
* | ||
* Class to manage HTTP URI query parameters | ||
* | ||
* The HttpParams class was an empty HashMap class living in 'Structures.h'. | ||
* It has been expanded to incorporate escaping and unescaping. | ||
* Custom URL parsing code has been replaced with the yuarel library https://github.com/jacketizer/libyuarel | ||
* | ||
****/ | ||
|
||
#ifndef _SMINGCORE_HTTP_HTTP_PARAMS_H_ | ||
#define _SMINGCORE_HTTP_HTTP_PARAMS_H_ | ||
|
||
#include "WString.h" | ||
#include "WHashMap.h" | ||
#include "Printable.h" | ||
|
||
/** @brief | ||
* | ||
* @todo values stored in escaped form, unescape return value and escape provided values. | ||
* Revise HttpBodyParser.cpp as it will no longer do this job. | ||
* | ||
*/ | ||
class HttpParams : public HashMap<String, String>, public Printable | ||
{ | ||
public: | ||
// Printable | ||
virtual size_t printTo(Print& p) const; | ||
}; | ||
|
||
#endif // _SMINGCORE_HTTP_HTTP_PARAMS_H_ |
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