2
2
#define BENONI_HTTP_H_
3
3
4
4
#include < functional> // std::function
5
- #include < map> // std::map
5
+ #include < map> // std::multimap
6
6
#include < optional> // std::optional
7
7
#include < string> // std::string
8
8
#include < variant> // std::variant
@@ -27,12 +27,14 @@ class RequestOptions {
27
27
public:
28
28
Method method () const { return method_; }
29
29
const std::string &body () const { return body_; }
30
- const std::map<std::string, std::string> &headers () const { return headers_; }
30
+ const std::multimap<std::string, std::string> &headers () const {
31
+ return headers_;
32
+ }
31
33
const std::optional<int > &timeout () const { return timeout_; }
32
34
33
35
private:
34
36
RequestOptions (Method method, std::string body,
35
- std::map <std::string, std::string> headers,
37
+ std::multimap <std::string, std::string> headers,
36
38
std::optional<int > timeout)
37
39
: method_{method}, body_{std::move (body)}, headers_{std::move (headers)},
38
40
timeout_{std::move (timeout)} {}
@@ -41,7 +43,7 @@ class RequestOptions {
41
43
42
44
Method method_;
43
45
std::string body_;
44
- std::map <std::string, std::string> headers_;
46
+ std::multimap <std::string, std::string> headers_;
45
47
std::optional<int > timeout_;
46
48
};
47
49
@@ -58,7 +60,7 @@ class RequestOptionsBuilder {
58
60
}
59
61
60
62
RequestOptionsBuilder &
61
- set_headers (std::map <std::string, std::string> headers) {
63
+ set_headers (std::multimap <std::string, std::string> headers) {
62
64
headers_ = std::move (headers);
63
65
return *this ;
64
66
}
@@ -76,14 +78,14 @@ class RequestOptionsBuilder {
76
78
private:
77
79
Method method_ = Method::GET;
78
80
std::string body_;
79
- std::map <std::string, std::string> headers_;
81
+ std::multimap <std::string, std::string> headers_;
80
82
std::optional<int > timeout_;
81
83
};
82
84
83
85
struct Response {
84
86
std::string body;
85
87
uint16_t status;
86
- std::map <std::string, std::string> headers;
88
+ std::multimap <std::string, std::string> headers;
87
89
};
88
90
89
91
auto request (const std::string &url, RequestOptions options,
0 commit comments