-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples/protocols: Added URI encoding/decoding feature
- http_server/simple: Decoding received query - esp_http_client: Sending encoded query
- Loading branch information
1 parent
d825753
commit 167618d
Showing
7 changed files
with
500 additions
and
11 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
examples/common_components/protocol_examples_common/CMakeLists.txt
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
49 changes: 49 additions & 0 deletions
49
examples/common_components/protocol_examples_common/include/protocol_examples_utils.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,49 @@ | ||
/* | ||
* Utility functions for protocol examples | ||
* | ||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Unlicense OR CC0-1.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
|
||
/** | ||
* @brief Encode an URI | ||
* | ||
* @param dest a destination memory location | ||
* @param src the source string | ||
* @param len the length of the source string | ||
* @return uint32_t the count of escaped characters | ||
* | ||
* @note Please allocate the destination buffer keeping in mind that encoding a | ||
* special character will take up 3 bytes (for '%' and two hex digits). | ||
* In the worst-case scenario, the destination buffer will have to be 3 times | ||
* that of the source string. | ||
*/ | ||
uint32_t example_uri_encode(char *dest, const char *src, size_t len); | ||
|
||
/** | ||
* @brief Decode an URI | ||
* | ||
* @param dest a destination memory location | ||
* @param src the source string | ||
* @param len the length of the source string | ||
* | ||
* @note Please allocate the destination buffer keeping in mind that a decoded | ||
* special character will take up 2 less bytes than its encoded form. | ||
* In the worst-case scenario, the destination buffer will have to be | ||
* the same size that of the source string. | ||
*/ | ||
void example_uri_decode(char *dest, const char *src, size_t len); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
Oops, something went wrong.