|
3 | 3 |
|
4 | 4 | // Copyright 2010 (c) Dean Michael Berris
|
5 | 5 | // Copyright 2010 (c) Sinefunc, Inc.
|
| 6 | +// Copyright 2011 Dean Michael Berris ([email protected]). |
| 7 | +// Copyright 2011 Google, Inc. |
6 | 8 | // Distributed under the Boost Software License, Version 1.0.
|
7 | 9 | // (See accompanying file LICENSE_1_0.txt or copy at
|
8 | 10 | // http://www.boost.org/LICENSE_1_0.txt)
|
@@ -91,13 +93,15 @@ namespace boost { namespace network { namespace http {
|
91 | 93 | destination_ = future;
|
92 | 94 | }
|
93 | 95 |
|
94 |
| - headers_container_type const headers() const { |
| 96 | + headers_container_type const & headers() const { |
| 97 | + if (retrieved_headers_) return *retrieved_headers_; |
95 | 98 | headers_container_type raw_headers = headers_.get();
|
96 | 99 | raw_headers.insert(added_headers.begin(), added_headers.end());
|
97 | 100 | BOOST_FOREACH(string_type const & key, removed_headers) {
|
98 | 101 | raw_headers.erase(key);
|
99 | 102 | }
|
100 |
| - return raw_headers; |
| 103 | + retrieved_headers_ = raw_headers; |
| 104 | + return *retrieved_headers_; |
101 | 105 | }
|
102 | 106 |
|
103 | 107 | void headers(boost::shared_future<headers_container_type> const & future) const {
|
@@ -144,6 +148,7 @@ namespace boost { namespace network { namespace http {
|
144 | 148 | mutable headers_container_type added_headers;
|
145 | 149 | mutable std::set<string_type> removed_headers;
|
146 | 150 | mutable boost::shared_future<string_type> body_;
|
| 151 | + mutable boost::optional<headers_container_type> retrieved_headers_; |
147 | 152 |
|
148 | 153 | friend struct boost::network::http::impl::ready_wrapper<Tag>;
|
149 | 154 | };
|
|
0 commit comments