|
| 1 | +// Copyright 2010 Dean Michael Berris. |
| 2 | +// Distributed under the Boost Software License, Version 1.0. |
| 3 | +// (See accompanying file LICENSE_1_0.txt or copy at |
| 4 | +// http://www.boost.org/LICENSE_1_0.txt) |
| 5 | + |
| 6 | +#define BOOST_TEST_MODULE HTTP 1.0 Get Test |
| 7 | +#include <boost/network/include/http/client.hpp> |
| 8 | +#include <boost/test/unit_test.hpp> |
| 9 | +#include "tag_types.hpp" |
| 10 | + |
| 11 | +namespace net = boost::network; |
| 12 | +namespace http = boost::network::http; |
| 13 | + |
| 14 | + |
| 15 | +BOOST_AUTO_TEST_CASE_TEMPLATE(http_client_get_test, T, tag_types) { |
| 16 | + typedef http::basic_client<T, 1, 0> client; |
| 17 | + typename client::request request("http://www.boost.org"); |
| 18 | + client client_; |
| 19 | + typename client::response response; |
| 20 | + BOOST_CHECK_NO_THROW ( response = client_.get(request) ); |
| 21 | + typename net::headers_range<typename client::response>::type range = headers(response)["Content-Type"]; |
| 22 | + BOOST_CHECK ( !boost::empty(range) ); |
| 23 | + BOOST_CHECK ( body(response).size() != 0 ); |
| 24 | + BOOST_CHECK_EQUAL ( response.version().substr(0,7), std::string("HTTP/1.") ); |
| 25 | + BOOST_CHECK_EQUAL ( response.status(), 200u ); |
| 26 | + BOOST_CHECK_EQUAL ( response.status_message(), std::string("OK") ); |
| 27 | +} |
| 28 | + |
| 29 | +BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test, T, tag_types) { |
| 30 | + typedef http::basic_client<T, 1, 1> client; |
| 31 | + typename client::request request("http://www.boost.org/"); |
| 32 | + typename client::response response_; |
| 33 | + client client_; |
| 34 | + BOOST_CHECK_NO_THROW ( response_ = client_.get(request) ); |
| 35 | + typename net::headers_range<typename client::response>::type range = headers(response_)["Content-Type"]; |
| 36 | + BOOST_CHECK ( boost::begin(range) != boost::end(range) ); |
| 37 | + BOOST_CHECK ( body(response_).size() != 0 ); |
| 38 | + BOOST_CHECK_EQUAL ( response_.version().substr(0,7), std::string("HTTP/1.") ); |
| 39 | + BOOST_CHECK_EQUAL ( response_.status(), 200u ); |
| 40 | + BOOST_CHECK_EQUAL ( response_.status_message(), std::string("OK") ); |
| 41 | +} |
| 42 | + |
0 commit comments