Skip to content

Commit a573a4c

Browse files
committed
Updating the Concepts.
Due to the changes in the interfaces and removal for the requirement of static tag-based dispatch, the concepts had to be updated to reflect the now minimal requirements. This applies to the Message concept and the ClientRequest and ServerRequest concepts. For the same reason the modifiers for HTTP messages had to be updated to reflect the interface. Same goes for the wrappers that deal specifically with HTTP request objects. The steps taken here will allow for more forward progress in making the library more modular. Extension at a later time may require membership in the hierarchy but this should make it more familiar using OOP techniques. If it proves useful the wrappers, modifiers, and directives can be written in a generic approach -- the meat though of the message types would benefit from having a dynamic implementation for preserving binary compatibility.
1 parent 6a6875a commit a573a4c

File tree

18 files changed

+222
-203
lines changed

18 files changed

+222
-203
lines changed

boost/network/message/message_concept.hpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
#include <boost/network/message/wrappers.hpp>
1414
#include <boost/network/message/transformers.hpp>
1515
#include <boost/network/message/directives.hpp>
16+
#include <map>
1617

1718
namespace boost { namespace network {
1819

1920
template <class M>
2021
struct Message
2122
: DefaultConstructible<M>, CopyConstructible<M>, Assignable<M> {
22-
typedef typename M::string_type string_type;
23-
typedef typename M::headers_container_type headers_container_type;
2423

2524
BOOST_CONCEPT_USAGE(Message) {
2625
M message_;
@@ -31,18 +30,18 @@ namespace boost { namespace network {
3130
typedef std::string header_key_type;
3231
typedef std::string header_value_type;
3332

34-
headers_container_type headers_ = headers(message);
35-
string_type body_ = body(message);
36-
string_type source_ = source(message);
37-
string_type destination_ = destination(message);
33+
std::multimap<std::string, std::string> headers_ = headers(message);
34+
std::string body_ = body(message);
35+
std::string source_ = source(message);
36+
std::string destination_ = destination(message);
3837

3938
message << source(source_type())
4039
<< destination(destination_type())
41-
<< header(string_type(), string_type())
40+
<< header(std::string(), std::string())
4241
<< body(body_type());
4342

44-
add_header(message, string_type(), string_type());
45-
remove_header(message, string_type());
43+
add_header(message, std::string(), std::string());
44+
remove_header(message, std::string());
4645
clear_headers(message);
4746
source(message, source_type());
4847
destination(message, destination_type());

boost/network/message/modifiers.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef BOOST_NETWORK_MESSAGE_MODIFIERS_HPP_20111201
2+
#define BOOST_NETWORK_MESSAGE_MODIFIERS_HPP_20111201
3+
4+
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2011 Google, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include <boost/network/message/modifiers/add_header.hpp>
11+
#include <boost/network/message/modifiers/body.hpp>
12+
#include <boost/network/message/modifiers/clear_headers.hpp>
13+
#include <boost/network/message/modifiers/destination.hpp>
14+
#include <boost/network/message/modifiers/remove_header.hpp>
15+
#include <boost/network/message/modifiers/source.hpp>
16+
17+
#endif // BOOST_NETWORK_MESSAGE_MODIFIERS_HPP_20111201

boost/network/protocol/http/client/connection/async_resolver.ipp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <boost/algorithm/string/case_conv.hpp>
2121
#include <boost/fusion/tuple.hpp>
2222
#include <boost/fusion/adapted/std_pair.hpp>
23+
#include <boost/scoped_ptr.hpp>
2324
#include <boost/network/protocol/http/client/connection/async_resolver.hpp>
2425

2526
namespace boost { namespace network { namespace http {

boost/network/protocol/http/client/connection/simple_connection_factory.ipp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct simple_connection_factory_pimpl {
3737
service, https, openssl_certificate, openssl_verify_path),
3838
service,
3939
follow_redirects));
40+
return conn_;
4041
}
4142

4243
private:

boost/network/protocol/http/client/simple_connection_manager.ipp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct simple_connection_manager_pimpl {
1717
optional<std::string> openssl_certificate,
1818
optional<std::string> openssl_verify_path,
1919
shared_ptr<connection_factory> connection_factory)
20-
: cache_resolved_(cache_resolved_)
20+
: cache_resolved_(cache_resolved)
2121
, follow_redirects_(follow_redirects)
2222
, openssl_certificate_(openssl_certificate)
2323
, openssl_verify_path_(openssl_verify_path)
@@ -29,7 +29,7 @@ struct simple_connection_manager_pimpl {
2929
std::string const & openssl_certificate,
3030
std::string const & openssl_verify_path,
3131
shared_ptr<connection_factory> connection_factory)
32-
: cache_resolved_(cache_resolved_)
32+
: cache_resolved_(cache_resolved)
3333
, follow_redirects_(follow_redirects)
3434
, openssl_certificate_(openssl_certificate)
3535
, openssl_verify_path_(openssl_verify_path)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201
2+
#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201
3+
4+
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2011 Google, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include <boost/network/protocol/http/message/directives/method.hpp>
11+
#include <boost/network/protocol/http/message/directives/status.hpp>
12+
#include <boost/network/protocol/http/message/directives/status_message.hpp>
13+
#include <boost/network/protocol/http/message/directives/uri.hpp>
14+
#include <boost/network/protocol/http/message/directives/version.hpp>
15+
16+
#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_DIRECTIVES_HPP_20111201
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201
2+
#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201
3+
4+
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2011 Google, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include <boost/network/protocol/http/message/modifiers/method.hpp>
11+
#include <boost/network/protocol/http/message/modifiers/status.hpp>
12+
#include <boost/network/protocol/http/message/modifiers/status_message.hpp>
13+
#include <boost/network/protocol/http/message/modifiers/uri.hpp>
14+
#include <boost/network/protocol/http/message/modifiers/version.hpp>
15+
16+
#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_MODIFIERS_HPP_20111201

boost/network/protocol/http/message/modifiers/uri.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@
33

44
// Copyright 2010 (c) Dean Michael Berris
55
// Copyright 2010 (c) Sinefunc, Inc.
6+
// Copyright 2011 Google, Inc.
67
// Distributed under the Boost Software License, Version 1.0.
78
// (See accompanying file LICENSE_1_0.txt or copy at
89
// http://www.boost.org/LICENSE_1_0.txt)
910

10-
#include <boost/thread/future.hpp>
11+
#include <boost/network/protocol/http/request/request_base.hpp>
1112

1213
namespace boost { namespace network { namespace http {
1314

14-
template <class Tag>
15-
struct basic_request;
15+
inline void uri(request_base & request, std::string const & value) {
16+
request.set_uri(value);
17+
}
1618

17-
template <class Tag, class T>
18-
void uri(basic_request<Tag> & request, T const & value) {
19-
request.uri(value);
20-
}
19+
inline void uri(request_base & request, uri::uri const & value) {
20+
request.set_uri(value);
21+
}
2122

2223
} // namespace http
2324

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201
2+
#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201
3+
4+
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2011 Google, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include <boost/network/protocol/http/message/wrappers/anchor.hpp>
11+
#include <boost/network/protocol/http/message/wrappers/helper.hpp>
12+
#include <boost/network/protocol/http/message/wrappers/host.hpp>
13+
#include <boost/network/protocol/http/message/wrappers/method.hpp>
14+
#include <boost/network/protocol/http/message/wrappers/path.hpp>
15+
#include <boost/network/protocol/http/message/wrappers/port.hpp>
16+
#include <boost/network/protocol/http/message/wrappers/protocol.hpp>
17+
#include <boost/network/protocol/http/message/wrappers/query.hpp>
18+
#include <boost/network/protocol/http/message/wrappers/ready.hpp>
19+
#include <boost/network/protocol/http/message/wrappers/status.hpp>
20+
#include <boost/network/protocol/http/message/wrappers/status_message.hpp>
21+
#include <boost/network/protocol/http/message/wrappers/uri.hpp>
22+
#include <boost/network/protocol/http/message/wrappers/version.hpp>
23+
24+
#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HPP_20111201

boost/network/protocol/http/message/wrappers/anchor.hpp

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,26 @@
33

44
// Copyright 2010 (c) Dean Michael Berris.
55
// Copyright 2010 (c) Sinefunc, Inc.
6+
// Copyright 2011 Google, Inc.
67
// Distributed under the Boost Software License, Version 1.0.
78
// (See accompanying file LICENSE_1_0.txt or copy at
89
// http://www.boost.org/LICENSE_1_0.txt)
910

11+
#include <boost/network/protocol/http/request/request_base.hpp>
12+
1013
namespace boost { namespace network { namespace http {
1114

12-
template <class Tag>
13-
struct basic_request;
14-
15-
namespace impl {
16-
template <class Tag>
17-
struct anchor_wrapper {
18-
basic_request<Tag> const & message_;
19-
anchor_wrapper(basic_request<Tag> const & message)
20-
: message_(message) {}
21-
typedef typename basic_request<Tag>::string_type string_type;
22-
operator string_type() {
23-
return message_.anchor();
24-
}
25-
};
26-
}
27-
28-
template <class Tag> inline
29-
impl::anchor_wrapper<Tag>
30-
anchor(basic_request<Tag> const & request) {
31-
return impl::anchor_wrapper<Tag>(request);
32-
}
15+
struct anchor_wrapper {
16+
explicit anchor_wrapper(request_base const & request);
17+
operator std::string () const;
18+
private:
19+
request_base const & request_;
20+
};
21+
22+
inline anchor_wrapper const
23+
anchor(request_base const & request) {
24+
return anchor_wrapper(request);
25+
}
3326

3427
} // namespace http
3528

0 commit comments

Comments
 (0)