Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce3bccf

Browse files
committed
Validated that the HEAD response returns the headers.
1 parent619255a commitce3bccf

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

‎http/src/http/v2/client/client.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include<future>
77
#include<boost/asio/strand.hpp>
88
#include<boost/algorithm/string/trim.hpp>
9+
#include<boost/algorithm/string/split.hpp>
910
#include<boost/algorithm/string/predicate.hpp>
1011
#include<network/uri.hpp>
1112
#include<network/config.hpp>
@@ -171,6 +172,14 @@ namespace network {
171172
}
172173

173174
// fill headers
175+
std::istreamis(&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+
174183
connection_->async_read_until(response_,
175184
"\r\n\r\n",
176185
strand_.wrap(

‎http/src/network/http/v2/client/response.hpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ namespace network {
152152
return status_message_;
153153
}
154154

155+
voidadd_header(const string_type &name,const string_type &value) {
156+
headers_.push_back(std::make_pair(name, value));
157+
}
158+
155159
/**
156160
* \brief
157161
*/

‎http/test/v2/features/client/client_test.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ Describe(http_client) {
3434
Assert::That(response.version(),Equals("HTTP/1.1"));
3535
Assert::That(response.status(),Equals(http::status::code::OK));
3636
Assert::That(response.status_message(),Equals("OK"));
37+
38+
auto headers = response.headers();
39+
Assert::That(std::begin(headers)->first,Equals("Date"));
3740
}
3841

3942
std::unique_ptr<http::client> client_;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp