-
-
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.
Added example content decoder plugin explaining how to operate on bod…
…y data.
- Loading branch information
1 parent
057bb13
commit bf3d5a3
Showing
8 changed files
with
85 additions
and
40 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
37 changes: 37 additions & 0 deletions
37
Sming/Components/Network/src/Network/Http/Resource/Content/DecoderContent.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
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: 2021 - Slavey Karadzhov <[email protected]> | ||
* | ||
****/ | ||
|
||
#pragma once | ||
|
||
#include "../HttpResourcePlugin.h" | ||
#include <Data/WebHelpers/base64.h> | ||
|
||
class DecoderContent : public HttpResourcePlugin | ||
{ | ||
bool registerPlugin(HttpEventedResource& resource) override | ||
{ | ||
// Check if the provided content is encoded in some way | ||
return resource.addEvent( | ||
HttpEventedResource::EVENT_BODY, | ||
[](HttpServerConnection& connection, char** at, int* length) { | ||
auto request = connection.getRequest(); | ||
if(request->headers[HTTP_HEADER_CONTENT_ENCODING] == "test") { | ||
char* data = *at; | ||
for(unsigned i = 0; i < *length; i++) { | ||
data[i]++; | ||
} | ||
} | ||
|
||
return true; | ||
}, | ||
1); | ||
} | ||
}; |
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