|
8 | 8 | #include <boost/test/unit_test.hpp> |
9 | 9 | #include <boost/network.hpp> |
10 | 10 | #include <iostream> |
| 11 | +#include <boost/mpl/list.hpp> |
11 | 12 |
|
12 | | -BOOST_AUTO_TEST_CASE(http_get_test) { |
13 | | - using namespace boost::network; |
14 | | - http::request request("http://www.boost.org/"); |
15 | | - http::client client_; |
16 | | - http::response response_; |
| 13 | +using namespace boost::network; |
| 14 | + |
| 15 | +typedef boost::mpl::list<tags::http_default_8bit_tcp_resolve, tags::http_default_8bit_udp_resolve> tag_types; |
| 16 | + |
| 17 | +BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test, T, tag_types) { |
| 18 | + http::basic_request<T> request("http://www.boost.org/"); |
| 19 | + http::basic_client<T, 1, 0> client_; |
| 20 | + http::basic_response<T> response_; |
17 | 21 | response_ = client_.get(request); |
18 | | - headers_range<http::response>::type range = headers(response_)["Content-Type"]; |
| 22 | + typename headers_range<typename http::basic_response<T> >::type range = headers(response_)["Content-Type"]; |
19 | 23 | BOOST_CHECK ( begin(range) != end(range) ); |
20 | 24 | BOOST_CHECK ( body(response_).size() != 0 ); |
21 | 25 | } |
22 | 26 |
|
23 | | -BOOST_AUTO_TEST_CASE(http_get_test_different_port) { |
24 | | - using namespace boost::network; |
25 | | - http::request request("http://www.boost.org:80/"); |
26 | | - http::client client_; |
27 | | - http::response response_; |
| 27 | +BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_different_port, T, tag_types) { |
| 28 | + http::basic_request<T> request("http://www.boost.org:80/"); |
| 29 | + http::basic_client<T, 1, 0> client_; |
| 30 | + http::basic_response<T> response_; |
28 | 31 | response_ = client_.get(request); |
29 | | - headers_range<http::response>::type range = headers(response_)["Content-Type"]; |
| 32 | + typename headers_range<typename http::basic_response<T> >::type range = headers(response_)["Content-Type"]; |
30 | 33 | BOOST_CHECK ( begin(range) != end(range) ); |
31 | 34 | BOOST_CHECK ( body(response_).size() != 0 ); |
32 | 35 | } |
33 | 36 |
|
34 | | -BOOST_AUTO_TEST_CASE(http_get_test_timeout) { |
35 | | - using namespace boost::network; |
36 | | - http::request request("http://localhost:12121/"); |
37 | | - http::client client_; |
38 | | - http::response response_; |
| 37 | +BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout, T, tag_types) { |
| 38 | + http::basic_request<T> request("http://localhost:12121/"); |
| 39 | + http::basic_client<T, 1, 0> client_; |
| 40 | + http::basic_response<T> response_; |
39 | 41 | BOOST_CHECK_THROW ( response_ = client_.get(request), boost::system::system_error ); |
40 | 42 | } |
41 | 43 |
|
42 | | -BOOST_AUTO_TEST_CASE(http_get_details) { |
43 | | - using namespace boost::network; |
44 | | - http::request request("http://www.boost.org/"); |
45 | | - http::client client_; |
46 | | - http::response response_; |
| 44 | +BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_details, T, tag_types) { |
| 45 | + http::basic_request<T> request("http://www.boost.org/"); |
| 46 | + http::basic_client<T, 1, 0> client_; |
| 47 | + http::basic_response<T> response_; |
47 | 48 | BOOST_CHECK_NO_THROW ( response_ = client_.get(request) ); |
48 | 49 | BOOST_CHECK_EQUAL ( response_.version().substr(0,7), std::string("HTTP/1.") ); |
49 | 50 | BOOST_CHECK_EQUAL ( response_.status(), 200u ); |
50 | 51 | BOOST_CHECK_EQUAL ( response_.status_message(), std::string("OK") ); |
51 | 52 | } |
52 | 53 |
|
53 | | -BOOST_AUTO_TEST_CASE(http_cached_resolve) { |
54 | | - using namespace boost::network; |
55 | | - http::request request("http://www.boost.org"); |
56 | | - http::request other_request("http://www.boost.org/users/license.html"); |
57 | | - http::client client_(http::client::cache_resolved); |
58 | | - http::response response_; |
| 54 | +BOOST_AUTO_TEST_CASE_TEMPLATE(http_cached_resolve, T, tag_types) { |
| 55 | + http::basic_request<T> request("http://www.boost.org"); |
| 56 | + http::basic_request<T> other_request("http://www.boost.org/users/license.html"); |
| 57 | + http::basic_client<T,1,0> client_(http::basic_client<T,1,0>::cache_resolved); |
| 58 | + http::basic_response<T> response_; |
59 | 59 | BOOST_CHECK_NO_THROW ( response_ = client_.get(request) ); |
60 | 60 | BOOST_CHECK_NO_THROW ( response_ = client_.get(other_request) ); |
61 | 61 | } |
62 | 62 |
|
63 | | -BOOST_AUTO_TEST_CASE(http_redirection_test) { |
64 | | - using namespace boost::network; |
65 | | - http::request request("http://boost.org"); |
66 | | - http::client client_(http::client::follow_redirect); |
67 | | - http::response response_; |
| 63 | +BOOST_AUTO_TEST_CASE_TEMPLATE(http_redirection_test, T, tag_types) { |
| 64 | + http::basic_request<T> request("http://boost.org"); |
| 65 | + http::basic_client<T,1,0> client_(http::basic_client<T,1,0>::follow_redirect); |
| 66 | + http::basic_response<T> response_; |
68 | 67 | BOOST_CHECK_NO_THROW ( response_ = client_.get(request) ); |
69 | 68 | BOOST_CHECK_EQUAL ( response_.status(), 200u ); |
70 | 69 | } |
| 70 | + |
0 commit comments