Skip to content

Commit c36f908

Browse files
committed
Various fixes and implementation changes/
1 parent c118020 commit c36f908

File tree

10 files changed

+33
-38
lines changed

10 files changed

+33
-38
lines changed

boost/network/message/directives/destination.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ namespace boost { namespace network {
8787
Message const & message_;
8888
destination_visitor(Message const & message)
8989
: message_(message) {}
90-
void operator()(typename value<typename Message::tag>::type const & destination) const {
90+
void operator()(typename value<typename Message::tag>::type & destination) const {
9191
message_.destination(destination);
9292
}
9393
template <class T> void operator() (T const &) const {

boost/network/message/directives/header.hpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@
1313
#include <boost/thread/future.hpp>
1414
#include <boost/mpl/if.hpp>
1515
#include <boost/mpl/or.hpp>
16+
#include <boost/variant/variant.hpp>
17+
#include <boost/variant/apply_visitor.hpp>
18+
#include <boost/variant/static_visitor.hpp>
1619

17-
/** header.hpp
18-
*
19-
* Defines the types involved and the semantics of adding
20-
* header information into message objects.
21-
*
22-
* WARNING: DO NOT INCLUDE THIS HEADER DIRECTLY. THIS REQUIRES
23-
* TYPES TO BE DEFINED FROM EARLIER FILES THAT INCLUDE THIS
24-
* HEADER.
25-
*/
2620
namespace boost { namespace network {
2721

2822
namespace traits {
@@ -67,12 +61,12 @@ namespace boost { namespace network {
6761
} // namespace traits
6862

6963
namespace impl {
70-
71-
template <class T1, class T2>
64+
65+
template <class KeyType, class ValueType>
7266
struct header_directive {
7367

74-
explicit header_directive(T1 header_name,
75-
T2 header_value) :
68+
explicit header_directive(KeyType const & header_name,
69+
ValueType const & header_value) :
7670
_header_name(header_name),
7771
_header_value(header_value)
7872
{ };
@@ -85,8 +79,8 @@ struct header_directive {
8579

8680
private:
8781

88-
T1 const & _header_name;
89-
T2 const & _header_value;
82+
KeyType const & _header_name;
83+
ValueType const & _header_value;
9084
};
9185
} // namespace impl
9286

boost/network/message/directives/source.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ namespace boost { namespace network {
9292
typedef typename Message::tag Tag;
9393
source_visitor(Message const & message)
9494
: message_(message) {}
95-
void operator()(typename value<Tag>::type const & source) const {
95+
void operator()(typename value<Tag>::type & source) const {
9696
message_.source(source);
9797
}
9898
template <class T> void operator()(T const &) const {

boost/network/protocol/http/impl/sync_connection_base.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ namespace boost { namespace network { namespace http { namespace impl {
9696
name = header_line.substr(0, colon_offset);
9797
response_
9898
<< header(name, header_line.substr(colon_offset+2));
99-
};
100-
};
99+
}
100+
}
101101
}
102102

103103
template <class Socket>

boost/network/protocol/http/message.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ namespace boost { namespace network { namespace http {
7878
public:
7979

8080
message_impl()
81-
: version_(), status_(0u), status_message_()
81+
: base_type(), version_(), status_(0u), status_message_()
8282
{}
8383

8484
message_impl(message_impl const & other)
85-
: version_(other.version_), status_(other.status_), status_message_(other.status_message_)
85+
: base_type(other), version_(other.version_), status_(other.status_), status_message_(other.status_message_)
8686
{}
8787

8888
void version(string_type const & version) const {
@@ -115,8 +115,8 @@ namespace boost { namespace network { namespace http {
115115
}
116116

117117
void swap(message_impl & other) {
118-
basic_message<Tag> & base_ref(other),
119-
this_ref(*this);
118+
base_type & base_ref(other),
119+
& this_ref(*this);
120120
std::swap(this_ref, base_ref);
121121
std::swap(status_, other.status_);
122122
std::swap(status_message_, other.status_message_);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace boost { namespace network { namespace http {
2828
: message_(message) {}
2929
body_wrapper(body_wrapper const & other)
3030
: message_(other.message_) {}
31-
operator string_type const () {
31+
operator string_type () {
3232
return message_.body();
3333
}
3434
};

boost/network/protocol/http/policies/pooled_connection.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <boost/network/protocol/http/detail/connection_helper.hpp>
1414
#include <boost/network/protocol/http/impl/sync_connection_base.hpp>
1515
#include <boost/algorithm/string/predicate.hpp>
16+
#include <boost/network/protocol/http/response.hpp>
1617
#include <utility>
1718

1819
#ifndef BOOST_NETWORK_HTTP_MAXIMUM_REDIRECT_COUNT
@@ -62,7 +63,7 @@ namespace boost { namespace network { namespace http {
6263
pimpl->init_socket(request_.host(), lexical_cast<string_type>(request_.port()));
6364
}
6465
response_ = basic_response<Tag>();
65-
response_ << source(request_.host());
66+
response_ << ::boost::network::source(request_.host());
6667

6768
pimpl->send_request_impl(method, request_);
6869
boost::asio::streambuf response_buffer;
@@ -109,7 +110,6 @@ namespace boost { namespace network { namespace http {
109110
} else throw std::runtime_error("Location header not defined in redirect response.");
110111
}
111112
}
112-
113113
return response_;
114114
} while(true);
115115
}

boost/network/protocol/http/policies/simple_connection.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ namespace boost { namespace network { namespace http {
6262
} else break;
6363
} else break;
6464
} while(true);
65-
6665
return response_;
6766
}
6867

libs/network/example/http_client.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,18 @@ int main(int argc, char * argv[]) {
5858
typedef http::basic_client<tags::http_keepalive_8bit_udp_resolve, 1, 1>
5959
http_client;
6060

61-
6261
http_client::request request(source);
63-
request << header("Connection", "close");
62+
http_client::string_type destination_ = host(request);
63+
64+
request << ::boost::network::header("Connection", "close");
6465
http_client client(http_client::follow_redirects);
6566
http_client::response response = client.get(request);
66-
67+
6768
if (show_headers) {
6869
headers_range<http_client::response>::type headers_ = headers(response);
6970
boost::range_iterator<headers_range<http_client::response>::type>::type header, past_end;
70-
header = begin(headers_);
71-
past_end = end(headers_);
71+
header = boost::begin(headers_);
72+
past_end = boost::end(headers_);
7273
while (header != past_end) {
7374
cout << header->first << ": " << header->second << endl;
7475
++header;

libs/network/test/http_message_test.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,22 @@ BOOST_AUTO_TEST_CASE_TEMPLATE (response_assignment_construct_test, T, tag_types)
160160
}
161161

162162
BOOST_AUTO_TEST_CASE_TEMPLATE (response_swap_test, T, tag_types) {
163+
using namespace boost::network::http;
163164
http::basic_response<T> response;
164-
response.version() = "HTTP/1.1";
165-
response.status() = 200;
166-
response.status_message() = "OK";
167-
response << boost::network::body("RESPONSE");
165+
response << version("HTTP/1.1")
166+
<< status(200)
167+
<< status_message("OK")
168+
<< body("RESPONSE");
168169
boost::network::http::basic_response<T> swapped;
169170
BOOST_REQUIRE_NO_THROW(swap(response, swapped));
170171
BOOST_CHECK_EQUAL ( response.version(), std::string() );
171172
BOOST_CHECK_EQUAL ( response.status(), 0u );
172173
BOOST_CHECK_EQUAL ( response.status_message(), std::string() );
173-
BOOST_CHECK_EQUAL ( boost::network::body(response), std::string() );
174+
BOOST_CHECK_EQUAL ( body(response), std::string() );
174175
BOOST_CHECK_EQUAL ( swapped.version(), std::string("HTTP/1.1") );
175176
BOOST_CHECK_EQUAL ( swapped.status(), 200u );
176177
BOOST_CHECK_EQUAL ( swapped.status_message(), std::string("OK") );
177-
BOOST_CHECK_EQUAL ( boost::network::body(swapped), std::string("RESPONSE") );
178+
BOOST_CHECK_EQUAL ( body(swapped), std::string("RESPONSE") );
178179
}
179180

180181
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)