112 std::pair<std::string, std::string>
str_split(
const std::string& base,
char c_middle) {
113 std::pair<std::string, std::string> split;
115 const unsigned long middle = base.find_first_of(c_middle);
117 split.first = base.substr(0, middle);
119 if (middle != std::string::npos) {
120 split.second = base.substr(middle + 1);
126 std::pair<std::string, std::string>
str_split_last(
const std::string& base,
char c_middle) {
127 std::pair<std::string, std::string> split;
129 const unsigned long middle = base.find_last_of(c_middle);
131 split.first = base.substr(0, middle);
133 if (middle != std::string::npos) {
134 split.second = base.substr(middle + 1);
183 const std::string& url,
184 const std::string& version,
185 const web::http::
CiStringMap<std::string>& queries,
187 const web::http::
CiStringMap<std::string>& trailer,
188 const web::http::
CiStringMap<std::string>& cookies,
189 const std::vector<
char>& body) {
190 const int prefixLength = 9;
193 for (
const auto& [key, value] : queries) {
194 keyLength = std::max(keyLength,
static_cast<
int>(key.size()));
196 for (
const auto& [key, value] : header) {
197 keyLength = std::max(keyLength,
static_cast<
int>(key.size()));
199 for (
const auto& [key, value] : trailer) {
200 keyLength = std::max(keyLength,
static_cast<
int>(key.size()));
202 for (
const auto& [key, value] : cookies) {
203 keyLength = std::max(keyLength,
static_cast<
int>(key.size()));
206 std::stringstream requestStream;
208 requestStream << std::setw(prefixLength) <<
"Request"
209 <<
": " << std::setw(keyLength) <<
"Method"
210 <<
" : " << method <<
"\n";
211 requestStream << std::setw(prefixLength) <<
""
212 <<
": " << std::setw(keyLength) <<
"Url"
213 <<
" : " << url <<
"\n";
214 requestStream << std::setw(prefixLength) <<
""
215 <<
": " << std::setw(keyLength) <<
"Version"
216 <<
" : " << version <<
"\n";
220 if (!queries.empty()) {
222 for (
const auto& [query, value] : queries) {
223 requestStream << std::setw(prefixLength) << prefix <<
": " << std::setw(keyLength) << query <<
" : " << value <<
"\n";
228 if (!header.empty()) {
230 for (
const auto& [field, value] : header) {
231 requestStream << std::setw(prefixLength) << prefix <<
": " << std::setw(keyLength) << field <<
" : " << value <<
"\n";
236 if (!trailer.empty()) {
238 for (
const auto& [field, value] : trailer) {
239 requestStream << std::setw(prefixLength) << prefix <<
": " << std::setw(keyLength) << field <<
" : " << value <<
"\n";
244 if (!cookies.empty()) {
246 for (
const auto& [cookie, value] : cookies) {
247 requestStream << std::setw(prefixLength) << prefix <<
": " << std::setw(keyLength) << cookie <<
" : " << value <<
"\n";
254 requestStream << std::setw(prefixLength) << prefix << utils
::hexDump(body
, prefixLength
) <<
"\n";
257 std::string string = requestStream.str();
258 if (!string.empty()) {
266 const std::string& statusCode,
267 const std::string& reason,
270 const std::vector<
char>& body) {
271 const int prefixLength = 9;
274 for (
const auto& [key, value] : header) {
275 keyLength = std::max(keyLength,
static_cast<
int>(key.size()));
277 for (
const auto& [key, value] : cookies) {
278 keyLength = std::max(keyLength,
static_cast<
int>(key.size()));
281 std::stringstream requestStream;
283 requestStream << std::setw(prefixLength) <<
"Response"
284 <<
": " << std::setw(keyLength) <<
"Version"
285 <<
" : " << version <<
"\n";
286 requestStream << std::setw(prefixLength) <<
""
287 <<
": " << std::setw(keyLength) <<
"Status"
288 <<
" : " << statusCode <<
"\n";
289 requestStream << std::setw(prefixLength) <<
""
290 <<
": " << std::setw(keyLength) <<
"Reason"
291 <<
" : " << reason <<
"\n";
295 if (!header.empty()) {
297 for (
const auto& [field, value] : header) {
298 requestStream << std::setw(prefixLength) << prefix <<
": " << std::setw(keyLength) << field <<
" : " << value <<
"\n";
303 if (!cookies.empty()) {
305 for (
const auto& [cookie, options] : cookies) {
306 requestStream << std::setw(prefixLength) << prefix <<
": " << std::setw(keyLength) << cookie <<
" : " << options
.getValue()
308 for (
const auto& [optionKey, optionValue] : options
.getOptions()) {
309 requestStream << std::setw(prefixLength) <<
""
310 <<
":" << std::setw(keyLength) <<
""
311 <<
" : " << optionKey <<
"=" << optionValue <<
"\n";
319 requestStream << std::setw(prefixLength) << prefix << utils
::hexDump(body
, prefixLength
) <<
"\n";
322 std::string string = requestStream.str();
323 if (!string.empty()) {