47 for (std::string::const_iterator i = text.begin(), n = text.end(); i != n; ++i) {
48 const std::string::value_type c = (*i);
51 if ((i[1] != 0) && (i[2] != 0)) {
52 escaped +=
static_cast<
char>(from_hex(i[1]) << 4 | from_hex(i[2]));
55 }
else if (c ==
'+') {
90 std::pair<std::string, std::string>
str_split(
const std::string& base,
char c_middle) {
91 std::pair<std::string, std::string> split;
93 const unsigned long middle = base.find_first_of(c_middle);
95 split.first = base.substr(0, middle);
97 if (middle != std::string::npos) {
98 split.second = base.substr(middle + 1);
104 std::pair<std::string, std::string>
str_split_last(
const std::string& base,
char c_middle) {
105 std::pair<std::string, std::string> split;
107 const unsigned long middle = base.find_last_of(c_middle);
109 split.first = base.substr(0, middle);
111 if (middle != std::string::npos) {
112 split.second = base.substr(middle + 1);
161 const std::string& url,
162 const std::string& version,
163 const web::http::
CiStringMap<std::string>& queries,
165 const web::http::
CiStringMap<std::string>& cookies,
166 const std::vector<
char>& body) {
167 const int prefixLength = 9;
170 for (
const auto& [key, value] : queries) {
171 keyLength = std::max(keyLength,
static_cast<
int>(key.size()));
173 for (
const auto& [key, value] : header) {
174 keyLength = std::max(keyLength,
static_cast<
int>(key.size()));
176 for (
const auto& [key, value] : cookies) {
177 keyLength = std::max(keyLength,
static_cast<
int>(key.size()));
180 std::stringstream requestStream;
182 requestStream << std::setw(prefixLength) <<
"Request"
183 <<
": " << std::setw(keyLength) <<
"Method"
184 <<
" : " << method <<
"\n";
185 requestStream << std::setw(prefixLength) <<
""
186 <<
": " << std::setw(keyLength) <<
"Url"
187 <<
" : " << url <<
"\n";
188 requestStream << std::setw(prefixLength) <<
""
189 <<
": " << std::setw(keyLength) <<
"Version"
190 <<
" : " << version <<
"\n";
194 if (!queries.empty()) {
196 for (
const auto& [query, value] : queries) {
197 requestStream << std::setw(prefixLength) << prefix <<
": " << std::setw(keyLength) << query <<
" : " << value <<
"\n";
202 if (!header.empty()) {
204 for (
const auto& [field, value] : header) {
205 requestStream << std::setw(prefixLength) << prefix <<
": " << std::setw(keyLength) << field <<
" : " << value <<
"\n";
210 if (!cookies.empty()) {
212 for (
const auto& [cookie, value] : cookies) {
213 requestStream << std::setw(prefixLength) << prefix <<
": " << std::setw(keyLength) << cookie <<
" : " << value <<
"\n";
220 requestStream << std::setw(prefixLength) << prefix << utils::hexDump(body, prefixLength) <<
"\n";
223 std::string string = requestStream.str();
224 if (!string.empty()) {
232 const std::string& statusCode,
233 const std::string& reason,
235 const web::http::
CiStringMap<web::http::CookieOptions>& cookies,
236 const std::vector<
char>& body) {
237 const int prefixLength = 9;
240 for (
const auto& [key, value] : header) {
241 keyLength = std::max(keyLength,
static_cast<
int>(key.size()));
243 for (
const auto& [key, value] : cookies) {
244 keyLength = std::max(keyLength,
static_cast<
int>(key.size()));
247 std::stringstream requestStream;
249 requestStream << std::setw(prefixLength) <<
"Response"
250 <<
": " << std::setw(keyLength) <<
"Version"
251 <<
" : " << version <<
"\n";
252 requestStream << std::setw(prefixLength) <<
""
253 <<
": " << std::setw(keyLength) <<
"Status"
254 <<
" : " << statusCode <<
"\n";
255 requestStream << std::setw(prefixLength) <<
""
256 <<
": " << std::setw(keyLength) <<
"Reason"
257 <<
" : " << reason <<
"\n";
261 if (!header.empty()) {
263 for (
const auto& [field, value] : header) {
264 requestStream << std::setw(prefixLength) << prefix <<
": " << std::setw(keyLength) << field <<
" : " << value <<
"\n";
269 if (!cookies.empty()) {
271 for (
const auto& [cookie, options] : cookies) {
272 requestStream << std::setw(prefixLength) << prefix <<
": " << std::setw(keyLength) << cookie <<
" : " << options.getValue()
274 for (
const auto& [optionKey, optionValue] : options.getOptions()) {
275 requestStream << std::setw(prefixLength) <<
""
276 <<
":" << std::setw(keyLength) <<
""
277 <<
" : " << optionKey <<
"=" << optionValue <<
"\n";
285 requestStream << std::setw(prefixLength) << prefix << utils::hexDump(body, prefixLength) <<
"\n";
288 std::string string = requestStream.str();
289 if (!string.empty()) {