Skip to content

Commit 79d3fd6

Browse files
committed
Merging from mikhailberis/0.9-devel.
2 parents b46df4e + 4ab77ee commit 79d3fd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1992
-736
lines changed

CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@ if (OpenSSL_FOUND)
2121
endif()
2222

2323
if (Boost_FOUND)
24+
if (MSVC)
25+
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
26+
endif(MSVC)
27+
if (WIN32)
28+
add_definitions(-D_WIN32_WINNT=0x0501)
29+
endif(WIN32)
2430
include_directories(${Boost_INCLUDE_DIRS})
2531
enable_testing()
2632
add_subdirectory(libs/network/src)
2733
add_subdirectory(libs/network/test)
28-
add_subdirectory(libs/mime/test)
34+
if (NOT MSVC)
35+
add_subdirectory(libs/mime/test)
36+
endif(NOT MSVC)
2937
add_subdirectory(libs/network/example)
30-
endif()
31-
38+
endif(Boost_FOUND)
3239

40+
enable_testing()

boost/network/protocol/http/client/connection/async_base.hpp

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,64 @@
88
// http://www.boost.org/LICENSE_1_0.txt)
99

1010
#include <boost/network/protocol/http/response.hpp>
11+
#include <boost/network/protocol/http/client/connection/connection_delegate_factory.hpp>
12+
#include <boost/network/protocol/http/traits/delegate_factory.hpp>
1113
#include <boost/network/protocol/http/client/connection/async_normal.hpp>
12-
#ifdef BOOST_NETWORK_ENABLE_HTTPS
13-
#include <boost/network/protocol/http/client/connection/async_ssl.hpp>
14-
#endif
1514

1615
namespace boost { namespace network { namespace http { namespace impl {
1716

18-
template <class Tag, unsigned version_major, unsigned version_minor>
19-
struct async_connection_base {
20-
typedef typename resolver_policy<Tag>::type resolver_base;
21-
typedef typename resolver_base::resolver_type resolver_type;
22-
typedef typename resolver_base::resolve_function resolve_function;
23-
typedef typename string<Tag>::type string_type;
24-
typedef basic_request<Tag> request;
25-
typedef basic_response<Tag> response;
26-
typedef
27-
function<void(iterator_range<char const *> const &, system::error_code const &)>
28-
body_callback_function_type;
29-
30-
static boost::shared_ptr<async_connection_base<Tag,version_major,version_minor> > new_connection(resolve_function resolve, resolver_type & resolver, bool follow_redirect, bool https, optional<string_type> certificate_filename=optional<string_type>(), optional<string_type> const & verify_path=optional<string_type>()) {
31-
boost::shared_ptr<async_connection_base<Tag,version_major,version_minor> > temp;
32-
if (https) {
33-
#ifdef BOOST_NETWORK_ENABLE_HTTPS
34-
temp.reset(new https_async_connection<Tag,version_major,version_minor>(resolver, resolve, follow_redirect, certificate_filename, verify_path));
35-
return temp;
36-
#else
37-
throw std::runtime_error("HTTPS not supported.");
38-
#endif
39-
}
40-
temp.reset(new http_async_connection<Tag,version_major,version_minor>(resolver, resolve, follow_redirect));
41-
assert(temp.get() != 0);
42-
return temp;
43-
}
44-
45-
virtual response start(request const & request, string_type const & method, bool get_body, body_callback_function_type callback) = 0;
46-
47-
virtual ~async_connection_base() {}
48-
49-
};
17+
template <class Tag, unsigned version_major, unsigned version_minor>
18+
struct async_connection_base {
19+
typedef async_connection_base<Tag,version_major,version_minor> this_type;
20+
typedef typename resolver_policy<Tag>::type resolver_base;
21+
typedef typename resolver_base::resolver_type resolver_type;
22+
typedef typename resolver_base::resolve_function resolve_function;
23+
typedef typename string<Tag>::type string_type;
24+
typedef basic_request<Tag> request;
25+
typedef basic_response<Tag> response;
26+
typedef iterator_range<char const *> char_const_range;
27+
typedef function<void(char_const_range const &, system::error_code const &)>
28+
body_callback_function_type;
29+
typedef shared_ptr<this_type> connection_ptr;
30+
31+
// This is the factory function which constructs the appropriate async
32+
// connection implementation with the correct delegate chosen based on the
33+
// tag.
34+
static connection_ptr new_connection(
35+
resolve_function resolve,
36+
resolver_type & resolver,
37+
bool follow_redirect,
38+
bool https,
39+
optional<string_type> certificate_filename=optional<string_type>(),
40+
optional<string_type> const & verify_path=optional<string_type>()) {
41+
typedef http_async_connection<Tag,version_major,version_minor>
42+
async_connection;
43+
typedef typename delegate_factory<Tag>::type delegate_factory_type;
44+
connection_ptr temp;
45+
temp.reset(
46+
new async_connection(
47+
resolver,
48+
resolve,
49+
follow_redirect,
50+
delegate_factory_type::new_connection_delegate(
51+
resolver.get_io_service(),
52+
https,
53+
certificate_filename,
54+
verify_path)));
55+
BOOST_ASSERT(temp.get() != 0);
56+
return temp;
57+
}
58+
59+
// This is the pure virtual entry-point for all asynchronous connections.
60+
virtual response start(
61+
request const & request,
62+
string_type const & method,
63+
bool get_body,
64+
body_callback_function_type callback) = 0;
65+
66+
virtual ~async_connection_base() {}
67+
68+
};
5069

5170
} // namespace impl
5271

0 commit comments

Comments
 (0)