Skip to content

Commit df8eb44

Browse files
committed
Baby steps: request implementation.
In order to move on to getting the other tests to build, the request implementation needs to get to a point where it's building as well.
1 parent b59dcc5 commit df8eb44

File tree

5 files changed

+51
-38
lines changed

5 files changed

+51
-38
lines changed

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

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,20 @@
66
// (See accompanying file LICENSE_1_0.txt or copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
88

9-
#include <boost/network/protocol/http/support/is_server.hpp>
10-
#include <boost/utility/enable_if.hpp>
119
#include <boost/cstdint.hpp>
1210

1311
namespace boost { namespace network { namespace http {
1412

15-
template <class Tag>
16-
struct basic_request;
13+
struct major_version_directive {
14+
boost::uint8_t major_version;
15+
explicit major_version_directive(boost::uint8_t major_version);
16+
void operator()(request_base &request) const;
17+
};
1718

18-
struct major_version_directive {
19-
boost::uint8_t major_version;
20-
explicit major_version_directive(boost::uint8_t major_version)
21-
: major_version(major_version) {}
22-
template <class Tag>
23-
void operator()(basic_request<Tag> & request) const {
24-
request.http_version_major = major_version;
25-
}
26-
};
27-
28-
inline major_version_directive
29-
major_version(boost::uint8_t major_version_) {
30-
return major_version_directive(major_version_);
31-
}
19+
inline major_version_directive
20+
major_version(boost::uint8_t major_version_) {
21+
return major_version_directive(major_version_);
22+
}
3223

3324
} /* http */
3425

boost/network/protocol/http/request/request.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
// http://www.boost.org/LICENSE_1_0.txt)
99

1010
#include <boost/network/protocol/http/request/request_base.hpp>
11-
#include <boost/network/protocol/http/request/request_concept.hpp>
1211
#include <boost/network/uri/uri.hpp>
12+
#include <boost/network/protocol/http/message/directives/major_version.hpp>
13+
#include <boost/network/protocol/http/message/directives/minor_version.hpp>
14+
#include <boost/scoped_ptr.hpp>
1315

1416
namespace boost { namespace network { namespace http {
1517

@@ -20,8 +22,8 @@ struct request : request_base {
2022

2123
// We support full value semantics.
2224
request();
23-
explicit request(std::string url);
24-
explicit request(uri::uri url);
25+
explicit request(std::string const & url);
26+
explicit request(uri::uri const & url);
2527
request(request const &);
2628
request& operator=(request);
2729
void swap(request & other);
@@ -65,7 +67,7 @@ struct request : request_base {
6567

6668
virtual ~request();
6769
private:
68-
request_pimpl * pimpl_;
70+
scoped_ptr<request_pimpl> pimpl_;
6971
};
7072

7173
template <class Directive>
@@ -96,8 +98,4 @@ inline void swap(request &l, request &r) {
9698
#include <boost/network/protocol/http/message/modifiers.hpp>
9799
#include <boost/network/protocol/http/message/wrappers.hpp>
98100

99-
#ifdef BOOST_NETWORK_DEBUG
100-
BOOST_CONCEPT_ASSERT((boost::network::http::ClientRequest<boost::network::http::request>));
101-
#endif
102-
103101
#endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_REQUEST_HPP_20111021 */

boost/network/protocol/http/request/request.ipp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,32 @@
77
// (See accompanying file LICENSE_1_0.txt or copy at
88
// http://www.boost.org/LICENSE_1_0.txt)
99

10-
// TODO Implement the basic request proxy!
10+
#include <boost/network/protocol/http/request/request.hpp>
11+
#include <boost/network/protocol/http/request/request_concept.hpp>
12+
13+
#ifdef BOOST_NETWORK_DEBUG
14+
BOOST_CONCEPT_ASSERT((boost::network::http::ClientRequest<boost::network::http::request>));
15+
#endif
16+
17+
namespace boost { namespace network { namespace http {
18+
19+
struct request_pimpl {
20+
explicit request_pimpl(std::string const & url) {}
21+
};
22+
23+
request::~request() {
24+
// Do nothing here.
25+
}
26+
27+
request::request(std::string const & url)
28+
: pimpl_(new request_pimpl(url))
29+
{}
30+
31+
32+
} // namespace http
33+
34+
} // namespace network
35+
36+
} // namespace boost
1137

1238
#endif /* BOOST_NETWORK_PROTOCOL_HTTP_REQUEST_IPP_20110910 */

libs/network/src/http/request.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#undef BOOST_NETWORK_NO_LIB
99
#endif
1010

11+
#include <boost/network/protocol/http/request/request.ipp>
1112
#include <boost/network/protocol/http/request/request_base.ipp>
1213
#include <boost/network/protocol/http/message/wrappers/anchor.ipp>
1314
#include <boost/network/protocol/http/message/wrappers/host.ipp>

libs/network/test/http/client_get_different_port_test.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@
77
#define BOOST_TEST_MODULE HTTP Client Get Different Port Test
88
#include <boost/network/include/http/client.hpp>
99
#include <boost/test/unit_test.hpp>
10-
#include "client_types.hpp"
1110

12-
namespace net = boost::network;
13-
namespace http = boost::network::http;
14-
15-
BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_different_port, client, client_types) {
16-
typename client::request request("http://www.boost.org:80/");
17-
client client_;
18-
typename client::response response_ = client_.get(request);
19-
typename net::headers_range<typename client::response>::type range = headers(response_)["Content-Type"];
20-
BOOST_CHECK ( boost::begin(range) != boost::end(range) );
21-
BOOST_CHECK ( body(response_).size() != 0 );
11+
BOOST_AUTO_TEST_CASE(http_get_test_different_port) {
12+
using namespace boost::network::http;
13+
request request_("http://www.boost.org:80/");
14+
client client_;
15+
response response_ = client_.get(request_);
16+
boost::network::headers_wrapper::range_type headers_ = headers(response_)["Content-Type"];
17+
BOOST_CHECK( boost::begin(headers_) != boost::end(headers_) );
18+
BOOST_CHECK( body(response_).size() > 0 );
2219
}
2320

0 commit comments

Comments
 (0)