@@ -91,13 +91,15 @@ namespace boost { namespace network { namespace http {
9191 destination_ = future;
9292 }
9393
94- headers_container_typeconst headers ()const {
94+ headers_container_typeconst &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 ());
9798BOOST_FOREACH (string_typeconst & key, removed_headers) {
9899 raw_headers.erase (key);
99100 }
100- return raw_headers;
101+ retrieved_headers_ = raw_headers;
102+ return *retrieved_headers_;
101103 }
102104
103105void headers (boost::shared_future<headers_container_type>const & future)const {
@@ -144,6 +146,7 @@ namespace boost { namespace network { namespace http {
144146mutable headers_container_type added_headers;
145147mutable std::set<string_type> removed_headers;
146148mutable boost::shared_future<string_type> body_;
149+ mutable boost::optional<headers_container_type> retrieved_headers_;
147150
148151friend struct boost ::network::http::impl::ready_wrapper<Tag>;
149152 };