Skip to content

Commit 24e49cb

Browse files
committed
Major Surgery, aligning APIs.
So this set of changes moves forward the APIs of the internals of the client implementation. This is going to be more in flux until the request and response implementations get filled out. For the moment the "simplification" continues. WARNING: There's a lot of legacy code here still, most of which will not be kept. After this refactoring process is completed, the layout of the library will also change to better reflect the structure.
1 parent 80a073a commit 24e49cb

31 files changed

+1025
-546
lines changed

boost/network/message/message.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,21 @@ struct message : message_base {
4343
virtual void append_body(std::string const & data);
4444

4545
// Retrievers
46-
virtual void get_destination(std::string & destination);
47-
virtual void get_source(std::string & source);
46+
virtual void get_destination(std::string & destination) const;
47+
virtual void get_source(std::string & source) const;
4848
virtual void get_headers(
49-
function<void(std::string const &, std::string const &)> inserter);
49+
function<void(std::string const &, std::string const &)> inserter) const;
5050
virtual void get_headers(
5151
std::string const & name,
52-
function<void(std::string const &, std::string const &)> inserter);
52+
function<void(std::string const &, std::string const &)> inserter) const;
5353
virtual void get_headers(
5454
function<bool(std::string const &, std::string const &)> predicate,
55-
function<void(std::string const &, std::string const &)> inserter);
56-
virtual void get_body(std::string & body);
55+
function<void(std::string const &, std::string const &)> inserter) const;
56+
virtual void get_body(std::string & body) const;
5757
virtual void get_body(
5858
function<void(iterator_range<char const *>)> chunk_reader,
59-
size_t size);
59+
size_t size) const;
60+
6061
void swap(message & other);
6162

6263
// Destructor

boost/network/message/message.ipp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ struct message_pimpl {
5353
}
5454

5555
// Retrievers
56-
void get_destination(std::string & destination) {
56+
void get_destination(std::string & destination) const {
5757
destination = destination_;
5858
}
5959

60-
void get_source(std::string & source) {
60+
void get_source(std::string & source) const {
6161
source = source_;
6262
}
6363

64-
void get_headers(function<void(std::string const &, std::string const &)> inserter) {
64+
void get_headers(function<void(std::string const &, std::string const &)> inserter) const {
6565
std::multimap<std::string, std::string>::const_iterator it = headers_.begin(),
6666
end = headers_.end();
6767
for (; it != end; ++it) inserter(it->first, it->second);
6868
}
6969

7070
void get_headers(std::string const & name,
71-
function<void(std::string const &, std::string const &)> inserter) {
71+
function<void(std::string const &, std::string const &)> inserter) const {
7272
std::multimap<std::string, std::string>::const_iterator it = headers_.find(name),
7373
end= headers_.end();
7474
while (it != end) {
@@ -78,7 +78,7 @@ struct message_pimpl {
7878
}
7979

8080
void get_headers(function<bool(std::string const &, std::string const &)> predicate,
81-
function<void(std::string const &, std::string const &)> inserter) {
81+
function<void(std::string const &, std::string const &)> inserter) const {
8282
std::multimap<std::string, std::string>::const_iterator it = headers_.begin(),
8383
end = headers_.end();
8484
while (it != end) {
@@ -92,7 +92,7 @@ struct message_pimpl {
9292
body = body_;
9393
}
9494

95-
void get_body(function<void(iterator_range<char const *>)> chunk_reader, size_t size) {
95+
void get_body(function<void(iterator_range<char const *>)> chunk_reader, size_t size) const {
9696
static char const * nullptr_ = 0;
9797
if (body_read_pos == body_.size())
9898
chunk_reader(boost::make_iterator_range(nullptr_, nullptr_));
@@ -122,7 +122,7 @@ struct message_pimpl {
122122
std::multimap<std::string, std::string> headers_;
123123
// TODO: use Boost.IOStreams here later on.
124124
std::string body_;
125-
size_t body_read_pos;
125+
mutable size_t body_read_pos;
126126
};
127127

128128
message::message()
@@ -171,33 +171,33 @@ void message::append_body(std::string const & data) {
171171
pimpl->append_body(data);
172172
}
173173

174-
void message::get_destination(std::string & destination) {
174+
void message::get_destination(std::string & destination) const {
175175
pimpl->get_destination(destination);
176176
}
177177

178-
void message::get_source(std::string & source) {
178+
void message::get_source(std::string & source) const {
179179
pimpl->get_source(source);
180180
}
181181

182-
void message::get_headers(function<void(std::string const &, std::string const &)> inserter) {
182+
void message::get_headers(function<void(std::string const &, std::string const &)> inserter) const {
183183
pimpl->get_headers(inserter);
184184
}
185185

186186
void message::get_headers(std::string const & name,
187-
function<void(std::string const &, std::string const &)> inserter) {
187+
function<void(std::string const &, std::string const &)> inserter) const {
188188
pimpl->get_headers(name, inserter);
189189
}
190190

191191
void message::get_headers(function<bool(std::string const &, std::string const &)> predicate,
192-
function<void(std::string const &, std::string const &)> inserter) {
192+
function<void(std::string const &, std::string const &)> inserter) const {
193193
pimpl->get_headers(predicate, inserter);
194194
}
195195

196-
void message::get_body(std::string & body) {
196+
void message::get_body(std::string & body) const {
197197
pimpl->get_body(body);
198198
}
199199

200-
void message::get_body(function<void(iterator_range<char const *>)> chunk_reader, size_t size) {
200+
void message::get_body(function<void(iterator_range<char const *>)> chunk_reader, size_t size) const {
201201
pimpl->get_body(chunk_reader, size);
202202
}
203203

boost/network/message/message_base.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ struct message_base {
2424
virtual void append_body(std::string const & data) = 0;
2525

2626
// Retrievers
27-
virtual void get_destination(std::string & destination) = 0;
28-
virtual void get_source(std::string & source) = 0;
29-
virtual void get_headers(function<void(std::string const &, std::string const &)> inserter) = 0;
30-
virtual void get_headers(std::string const & name, function<void(std::string const &, std::string const &)> inserter) = 0;
31-
virtual void get_headers(function<bool(std::string const &, std::string const &)> predicate, function<void(std::string const &, std::string const &)> inserter) = 0;
32-
virtual void get_body(std::string & body) = 0;
33-
virtual void get_body(function<void(iterator_range<char const *>)> chunk_reader, size_t size) = 0;
27+
virtual void get_destination(std::string & destination) const = 0;
28+
virtual void get_source(std::string & source) const = 0;
29+
virtual void get_headers(function<void(std::string const &, std::string const &)> inserter) const = 0;
30+
virtual void get_headers(std::string const & name, function<void(std::string const &, std::string const &)> inserter) const = 0;
31+
virtual void get_headers(function<bool(std::string const &, std::string const &)> predicate, function<void(std::string const &, std::string const &)> inserter) const = 0;
32+
virtual void get_body(std::string & body) const = 0;
33+
virtual void get_body(function<void(iterator_range<char const *>)> chunk_reader, size_t size) const = 0;
3434

3535
// Destructor
3636
virtual ~message_base() = 0; // pure virtual

boost/network/message/wrappers/destination.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ namespace boost { namespace network {
1414
namespace impl {
1515

1616
struct destination_wrapper {
17-
explicit destination_wrapper(message_base & message);
17+
explicit destination_wrapper(message_base const & message);
1818
operator std::string () const;
1919
private:
20-
message_base & message_;
20+
message_base const & message_;
2121
mutable optional<std::string> cache_;
2222
};
2323

2424
} // namespace impl
2525

2626
inline std::string const
27-
destination(message_base & message_) {
27+
destination(message_base const & message_) {
2828
return impl::destination_wrapper(message_);
2929
}
3030

boost/network/message/wrappers/destination.ipp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace boost { namespace network { namespace impl {
1313

14-
destination_wrapper::destination_wrapper(message_base & message):
14+
destination_wrapper::destination_wrapper(message_base const & message):
1515
message_(message) {}
1616

1717
destination_wrapper::operator std::string () const {

boost/network/protocol/http/algorithms/linearize.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <boost/network/protocol/http/message/header/name.hpp>
1010
#include <boost/network/protocol/http/message/header/value.hpp>
1111
#include <boost/network/protocol/http/message/header_concept.hpp>
12-
#include <boost/network/protocol/http/request_concept.hpp>
12+
#include <boost/network/protocol/http/request/request_concept.hpp>
1313
#include <boost/network/constants.hpp>
1414
#include <boost/concept/requires.hpp>
1515
#include <boost/optional.hpp>

boost/network/protocol/http/client.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct client : basic_client_facade {
5858
(openssl_certificate, (std::string))
5959
(openssl_verify_path, (std::string))
6060
(connection_manager, (shared_ptr<connection_manager>))
61+
(connection_factory, (shared_ptr<connection_factory>))
6162
))
6263

6364
//

0 commit comments

Comments
 (0)