|
24 | 24 | #include <map>
|
25 | 25 |
|
26 | 26 | #include <boost/network/protocol/http/client/facade.hpp>
|
27 |
| -#include <boost/network/protocol/http/client/pimpl.hpp> |
| 27 | +#include <boost/network/protocol/http/client/parameters.hpp> |
28 | 28 |
|
29 | 29 | namespace boost { namespace network { namespace http {
|
30 | 30 |
|
31 | 31 | template <class Tag, unsigned version_major, unsigned version_minor>
|
32 | 32 | struct basic_client
|
33 |
| - : basic_client_facade<Tag, basic_client<Tag,version_major,version_minor> > |
| 33 | + : basic_client_facade<Tag, version_major, version_minor> |
34 | 34 | {
|
35 | 35 | private:
|
36 |
| - typedef basic_client_impl<Tag,version_major,version_minor> pimpl_type; |
37 |
| - typedef basic_client_facade<Tag, basic_client<Tag,version_major,version_minor> > base_facade_type; |
| 36 | + typedef basic_client_facade<Tag, version_major, version_minor> |
| 37 | + base_facade_type; |
38 | 38 | public:
|
39 | 39 | typedef basic_request<Tag> request;
|
40 | 40 | typedef basic_response<Tag> response;
|
41 | 41 | typedef typename string<Tag>::type string_type;
|
42 | 42 | typedef Tag tag_type;
|
43 | 43 |
|
44 |
| - struct cache_resolved_type { }; |
45 |
| - |
46 |
| - static cache_resolved_type cache_resolved() { |
47 |
| - return cache_resolved_type(); |
48 |
| - }; |
49 |
| - |
50 |
| - struct follow_redirect_type { }; |
51 |
| - |
52 |
| - static follow_redirect_type follow_redirects() { |
53 |
| - return follow_redirect_type(); |
54 |
| - }; |
55 |
| - |
56 |
| - static follow_redirect_type follow_redirect() { |
57 |
| - return follow_redirect_type(); |
58 |
| - }; |
59 |
| - |
60 |
| - // Constructors |
| 44 | + // Constructor |
61 | 45 | // =================================================================
|
62 |
| - basic_client() |
63 |
| - : base_facade_type(), pimpl(new pimpl_type(false, false)) |
64 |
| - {} |
65 |
| - |
66 |
| - explicit basic_client(cache_resolved_type (*)()) |
67 |
| - : base_facade_type(), pimpl(new pimpl_type(true, false)) |
68 |
| - {} |
69 |
| - |
70 |
| - explicit basic_client(follow_redirect_type (*)()) |
71 |
| - : base_facade_type(), pimpl(new pimpl_type(false, true)) |
72 |
| - {} |
73 |
| - |
74 |
| - basic_client(cache_resolved_type (*)(), follow_redirect_type (*)()) |
75 |
| - : base_facade_type(), pimpl(new pimpl_type(true, true)) |
76 |
| - {} |
77 |
| - |
78 |
| - explicit basic_client(boost::asio::io_service & io_service) |
79 |
| - : base_facade_type(), pimpl(new pimpl_type(false, false, io_service)) |
80 |
| - {} |
| 46 | + // This is a Boost.Parameter-based constructor forwarder, whose |
| 47 | + // implementation is actually forwarded to the base type. |
| 48 | + // |
| 49 | + // The supported parameters are: |
| 50 | + // _follow_redirects : bool -- whether to follow HTTP redirect |
| 51 | + // responses (default: false) |
| 52 | + // _cache_resolved : bool -- whether to cache the resolved |
| 53 | + // endpoints (default: false) |
| 54 | + // _io_service : boost::asio::io_service & |
| 55 | + // -- supply an io_service to the |
| 56 | + // client |
| 57 | + |
| 58 | + BOOST_PARAMETER_CONSTRUCTOR( |
| 59 | + basic_client, (base_facade_type), tag, |
| 60 | + (optional |
| 61 | + (in_out(io_service), (boost::asio::io_service)) |
| 62 | + (follow_redirects, (bool)) |
| 63 | + (cache_resolved, (bool)) |
| 64 | + )) |
81 | 65 |
|
82 | 66 | //
|
83 | 67 | // =================================================================
|
84 | 68 |
|
85 |
| - ~basic_client() |
86 |
| - {} |
87 |
| - |
88 |
| - private: |
89 |
| - |
90 |
| - boost::shared_ptr<pimpl_type> pimpl; |
91 |
| - |
92 |
| - friend struct basic_client_facade<Tag,basic_client<Tag,version_major,version_minor> > ; |
93 |
| - |
94 |
| - basic_response<Tag> const request_skeleton(request const & request_, string_type method, bool get_body) { |
95 |
| - return pimpl->request_skeleton(request_, method, get_body); |
96 |
| - } |
97 |
| - |
98 |
| - void clear_resolved_cache() { |
99 |
| - pimpl->clear_resolved_cache(); |
100 |
| - } |
101 |
| - |
102 | 69 | };
|
103 | 70 |
|
104 | 71 | typedef basic_client<tags::http_default_8bit_udp_resolve, 1, 0> client;
|
|
0 commit comments