File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 6
6
#include < future>
7
7
#include < boost/asio/strand.hpp>
8
8
#include < boost/algorithm/string/trim.hpp>
9
+ #include < boost/algorithm/string/split.hpp>
9
10
#include < boost/algorithm/string/predicate.hpp>
10
11
#include < network/uri.hpp>
11
12
#include < network/config.hpp>
@@ -171,6 +172,14 @@ namespace network {
171
172
}
172
173
173
174
// fill headers
175
+ std::istream is (&response_);
176
+ std::string header;
177
+ while ((header != " \r " ) && std::getline (is, header)) {
178
+ std::vector<string_type> kvp;
179
+ boost::split (kvp, header, boost::is_any_of (" :" ));
180
+ res->add_header (kvp[0 ], boost::trim_copy (kvp[1 ]));
181
+ }
182
+
174
183
connection_->async_read_until (response_,
175
184
" \r\n\r\n " ,
176
185
strand_.wrap (
Original file line number Diff line number Diff line change @@ -152,6 +152,10 @@ namespace network {
152
152
return status_message_;
153
153
}
154
154
155
+ void add_header (const string_type &name, const string_type &value) {
156
+ headers_.push_back (std::make_pair (name, value));
157
+ }
158
+
155
159
/* *
156
160
* \brief
157
161
*/
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ Describe(http_client) {
34
34
Assert::That (response.version (), Equals (" HTTP/1.1" ));
35
35
Assert::That (response.status (), Equals (http::status::code::OK));
36
36
Assert::That (response.status_message (), Equals (" OK" ));
37
+
38
+ auto headers = response.headers ();
39
+ Assert::That (std::begin (headers)->first , Equals (" Date" ));
37
40
}
38
41
39
42
std::unique_ptr<http::client> client_;
You can’t perform that action at this time.
0 commit comments