forked from awwit/httpserverapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequest.cpp
More file actions
54 lines (39 loc) · 988 Bytes
/
Request.cpp
File metadata and controls
54 lines (39 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "Request.h"
namespace HttpClient
{
std::string Request::getHeader(const std::string &key) const
{
auto it = headers.find(key);
return headers.end() != it ? it->second : "";
}
bool Request::isDataExists(const std::string &key) const
{
return data.cend() != data.find(key);
}
std::string Request::getDataAsString(const std::string &key) const
{
auto it = data.find(key);
return data.end() != it ? it->second : "";
}
std::vector<std::string> Request::getDataAsArray(const std::string &key) const
{
std::vector<std::string> arr;
size_t count = data.count(key);
if (count)
{
auto range = data.equal_range(key);
arr.resize(count);
size_t i = 0;
for (auto it = range.first; it != range.second; ++it)
{
arr[i++] = it->second;
}
}
return arr;
}
std::string Request::getCookieAsString(const std::string &cookieName) const
{
auto it = cookies.find(cookieName);
return cookies.end() != it ? it->second : "";
}
};