Skip to content

Commit 9956721

Browse files
committed
Fixes #56 -- caches asynchronously fetched headers.
1 parent 233b0f1 commit 9956721

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

boost/network/protocol/http/message/async_message.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,15 @@ namespace boost { namespace network { namespace http {
9191
destination_ = future;
9292
}
9393

94-
headers_container_type const headers() const {
94+
headers_container_type const & headers() const {
95+
if (retrieved_headers_) return *retrieved_headers_;
9596
headers_container_type raw_headers = headers_.get();
9697
raw_headers.insert(added_headers.begin(), added_headers.end());
9798
BOOST_FOREACH(string_type const & key, removed_headers) {
9899
raw_headers.erase(key);
99100
}
100-
return raw_headers;
101+
retrieved_headers_ = raw_headers;
102+
return *retrieved_headers_;
101103
}
102104

103105
void headers(boost::shared_future<headers_container_type> const & future) const {
@@ -144,6 +146,7 @@ namespace boost { namespace network { namespace http {
144146
mutable headers_container_type added_headers;
145147
mutable std::set<string_type> removed_headers;
146148
mutable boost::shared_future<string_type> body_;
149+
mutable boost::optional<headers_container_type> retrieved_headers_;
147150

148151
friend struct boost::network::http::impl::ready_wrapper<Tag>;
149152
};

0 commit comments

Comments
 (0)