mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-10 09:43:51 +00:00
Code format
This commit is contained in:
parent
40db42108f
commit
e9c6c6e609
17
httplib.h
17
httplib.h
@ -192,6 +192,7 @@ using socket_t = int;
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -203,7 +204,6 @@ using socket_t = int;
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <iomanip>
|
|
||||||
|
|
||||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
@ -1463,20 +1463,13 @@ inline std::string encode_query_param(const std::string &value){
|
|||||||
escaped << std::hex;
|
escaped << std::hex;
|
||||||
|
|
||||||
for (char const &c : value) {
|
for (char const &c : value) {
|
||||||
if (std::isalnum(c) ||
|
if (std::isalnum(c) || c == '-' || c == '_' || c == '.' || c == '!' ||
|
||||||
c == '-' ||
|
c == '~' || c == '*' || c == '\'' || c == '(' || c == ')') {
|
||||||
c == '_' ||
|
|
||||||
c == '.' ||
|
|
||||||
c == '!' ||
|
|
||||||
c == '~' ||
|
|
||||||
c == '*' ||
|
|
||||||
c == '\'' ||
|
|
||||||
c == '(' ||
|
|
||||||
c == ')') {
|
|
||||||
escaped << c;
|
escaped << c;
|
||||||
} else {
|
} else {
|
||||||
escaped << std::uppercase;
|
escaped << std::uppercase;
|
||||||
escaped << '%' << std::setw(2) << static_cast<int>(static_cast<unsigned char>(c));
|
escaped << '%' << std::setw(2)
|
||||||
|
<< static_cast<int>(static_cast<unsigned char>(c));
|
||||||
escaped << std::nouppercase;
|
escaped << std::nouppercase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,8 @@ TEST(EncodeQueryParamTest, ParseUnescapedChararactersTest){
|
|||||||
TEST(EncodeQueryParamTest, ParseReservedCharactersTest) {
|
TEST(EncodeQueryParamTest, ParseReservedCharactersTest) {
|
||||||
string reservedCharacters = ";,/?:@&=+$";
|
string reservedCharacters = ";,/?:@&=+$";
|
||||||
|
|
||||||
EXPECT_EQ(detail::encode_query_param(reservedCharacters), "%3B%2C%2F%3F%3A%40%26%3D%2B%24");
|
EXPECT_EQ(detail::encode_query_param(reservedCharacters),
|
||||||
|
"%3B%2C%2F%3F%3A%40%26%3D%2B%24");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TrimTests, TrimStringTests) {
|
TEST(TrimTests, TrimStringTests) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user