Skip to content

Commit 82bba85

Browse files
committed
Making client_get_streaming_test.cpp build.
1 parent 8e8b14e commit 82bba85

File tree

3 files changed

+29
-34
lines changed

3 files changed

+29
-34
lines changed

boost/network/protocol/http/message/directives/status.hpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,16 @@
1515

1616
namespace boost { namespace network { namespace http {
1717

18-
template <class String>
1918
struct status_directive {
20-
21-
status_directive(String const & s)
22-
: status_(s)
23-
{}
24-
25-
void operator()(response_base & response) {
26-
response.set_status(status_);
27-
}
19+
explicit status_directive(std::string const & s);
20+
void operator()(response_base & response) const;
2821

2922
protected:
30-
31-
String status_;
32-
23+
std::string status_;
3324
};
3425

35-
template <class String>
36-
inline status_directive<String> status(String const & response) {
37-
return status_directive<String>(response);
26+
inline status_directive status(std::string const & response) {
27+
return status_directive(response);
3828
}
3929

4030
} // namespace http

boost/network/protocol/http/message/wrappers/status.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace impl {
1616
struct status_wrapper {
1717
explicit status_wrapper(response_base & response_);
1818
operator std::string () const;
19+
operator uint16_t () const;
1920
private:
2021
response_base & response_;
2122
};

libs/network/test/http/client_get_streaming_test.cpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <boost/network/include/http/client.hpp>
88
#include <boost/test/unit_test.hpp>
99
#include <iostream>
10-
#include "client_types.hpp"
1110

1211
namespace net = boost::network;
1312
namespace http = boost::network::http;
@@ -26,23 +25,28 @@ struct body_handler {
2625
};
2726

2827

29-
BOOST_AUTO_TEST_CASE_TEMPLATE(http_client_get_streaming_test, client, async_only_client_types) {
30-
typename client::request request("http://www.boost.org");
31-
typename client::response response;
32-
typename client::string_type body_string;
33-
typename client::string_type dummy_body;
34-
body_handler handler_instance(body_string);
35-
{
36-
client client_;
37-
BOOST_CHECK_NO_THROW( response = client_.get(request, http::_body_handler=handler_instance) );
38-
typename net::headers_range<typename client::response>::type range = headers(response)["Content-Type"];
39-
BOOST_CHECK ( !boost::empty(range) );
40-
BOOST_CHECK_EQUAL ( body(response).size(), 0u );
41-
BOOST_CHECK_EQUAL ( response.version().substr(0, 7), std::string("HTTP/1.") );
42-
BOOST_CHECK_EQUAL ( response.status(), 200u );
43-
BOOST_CHECK_EQUAL ( response.status_message(), std::string("OK") );
44-
dummy_body = body(response);
45-
}
46-
BOOST_CHECK ( dummy_body == typename client::string_type() );
28+
BOOST_AUTO_TEST_CASE(http_client_get_streaming_test) {
29+
http::client::request request("http://www.boost.org");
30+
http::client::response response;
31+
std::string body_string;
32+
std::string dummy_body;
33+
body_handler handler_instance(body_string);
34+
{
35+
http::client client_;
36+
BOOST_CHECK_NO_THROW( response = client_.get(request, handler_instance) );
37+
net::headers_wrapper::range_type range = headers(response)["Content-Type"];
38+
BOOST_CHECK ( !boost::empty(range) );
39+
BOOST_CHECK_EQUAL ( body(response).size(), 0u );
40+
std::string version_, status_message_;
41+
boost::uint16_t status_;
42+
version_ = version(response);
43+
status_ = status(response);
44+
status_message_ = status_message(response);
45+
BOOST_CHECK_EQUAL ( version_.substr(0, 7), std::string("HTTP/1.") );
46+
BOOST_CHECK_EQUAL ( status_, 200u );
47+
BOOST_CHECK_EQUAL ( status_message_, std::string("OK") );
48+
dummy_body = body(response);
49+
}
50+
BOOST_CHECK ( dummy_body == std::string() );
4751
}
4852

0 commit comments

Comments
 (0)