3
3
// (See accompanying file LICENSE_1_0.txt or copy at
4
4
// http://www.boost.org/LICENSE_1_0.txt)
5
5
6
- #define BOOST_TEST_MODULE HTTP 1.0 Get Test
6
+ #define BOOST_TEST_MODULE HTTP Get Test
7
7
#include < boost/network/include/http/client.hpp>
8
8
#include < boost/test/unit_test.hpp>
9
9
#include " client_types.hpp"
@@ -16,10 +16,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(http_client_get_test, client, client_types) {
16
16
client client_;
17
17
typename client::response response;
18
18
BOOST_REQUIRE_NO_THROW (response = client_.get (request));
19
- typename net::headers_range<typename client::response>::type range =
20
- headers (response)[" Content-Type" ];
21
19
try {
22
20
auto data = body (response);
21
+ std::cout << data;
23
22
} catch (...) {
24
23
BOOST_ASSERT (false );
25
24
}
@@ -34,12 +33,11 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(https_client_get_test, client, client_types) {
34
33
typename client::request request (" https://www.github.com/" );
35
34
client client_;
36
35
typename client::response response = client_.get (request);
37
- typename net::headers_range<typename client::response>::type range =
38
- headers (response)[" Content-Type" ];
39
36
BOOST_CHECK (response.status () == 200 ||
40
37
(response.status () >= 300 && response.status () < 400 ));
41
38
try {
42
39
auto data = body (response);
40
+ std::cout << data;
43
41
} catch (...) {
44
42
BOOST_ASSERT (false );
45
43
}
@@ -48,14 +46,18 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(https_client_get_test, client, client_types) {
48
46
#endif
49
47
50
48
BOOST_AUTO_TEST_CASE_TEMPLATE (http_temp_client_get_test, client, client_types) {
51
- typename client::request request (" http://www.google.co.kr " );
49
+ typename client::request request (" http://cpp-netlib.org/ " );
52
50
typename client::response response;
53
51
BOOST_REQUIRE_NO_THROW (response = client ().get (request));
54
- typename net::headers_range<typename client::response>::type range =
55
- headers (response)[" Content-Type" ];
52
+ auto range = headers (response);
56
53
BOOST_CHECK (!boost::empty (range));
57
- BOOST_REQUIRE_NO_THROW (BOOST_CHECK (body (response).size () != 0 ));
54
+ try {
55
+ auto data = body (response);
56
+ std::cout << data;
57
+ } catch (...) {
58
+ BOOST_ASSERT (false );
59
+ }
58
60
BOOST_CHECK_EQUAL (response.version ().substr (0 , 7 ), std::string (" HTTP/1." ));
59
- BOOST_CHECK_EQUAL (response.status (), 200u );
60
- BOOST_CHECK_EQUAL (response.status_message (), std::string ( " OK " ));
61
+ BOOST_CHECK (response.status () == 200u ||
62
+ (response.status () >= 300 && response. status () < 400 ));
61
63
}
0 commit comments