Skip to content

Commit eeb590c

Browse files
committed
More Wrapper Implementations.
Here are a few more implementations of the wrappers required to get the necessary bits of the implementation out of the way. This clears up some fo the linker errors for the easier things that need to be dealt with. We also introduce a new lib for the constants used throughout the library. At some point later we're going to have to consolidate these constants not only from the HTTP implementation but also the URI implementation.
1 parent cfccb14 commit eeb590c

File tree

12 files changed

+182
-1
lines changed

12 files changed

+182
-1
lines changed

boost/network/constants.ipp

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

10+
#include <boost/network/constants.hpp>
11+
1012
namespace boost { namespace network {
1113

1214
char const * constants::crlf() {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_IPP_20111204
2+
#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_IPP_20111204
3+
4+
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2011 Googl,Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include <boost/network/protocol/http/message/wrappers/anchor.hpp>
11+
#include <boost/network/uri/uri.hpp>
12+
13+
namespace boost { namespace network { namespace http {
14+
15+
anchor_wrapper::anchor_wrapper(request_base const & request)
16+
: request_(request) {}
17+
18+
anchor_wrapper::operator std::string () const {
19+
uri::uri uri_;
20+
request_.get_uri(uri_);
21+
return fragment(uri_);
22+
}
23+
24+
} // namespace http
25+
26+
} // namespace network
27+
28+
} // namespace boost
29+
30+
#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_ANCHOR_IPP_20111204
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_IPP_20111204
2+
#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_IPP_20111204
3+
4+
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2011 Google, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include <boost/network/protocol/http/message/wrappers/host.hpp>
11+
#include <boost/network/uri/uri.hpp>
12+
13+
namespace boost { namespace network { namespace http {
14+
15+
host_wrapper::host_wrapper(request_base const & request)
16+
: request_(request) {}
17+
18+
host_wrapper::operator std::string () const {
19+
uri::uri uri_;
20+
request_.get_uri(uri_);
21+
return host(uri_);
22+
}
23+
24+
} // namespace http
25+
26+
} // namespace network
27+
28+
} // namespace boost
29+
30+
#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_IPP_20111204
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PATH_IPP_20111204
2+
#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PATH_IPP_20111204
3+
4+
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2011 Google, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include <boost/network/protocol/http/message/wrappers/path.hpp>
11+
#include <boost/network/uri/uri.hpp>
12+
13+
namespace boost { namespace network { namespace http {
14+
15+
path_wrapper::path_wrapper(request_base const & request)
16+
: request_(request) {}
17+
18+
path_wrapper::operator std::string () const {
19+
uri::uri uri_;
20+
request_.get_uri(uri_);
21+
return path(uri_);
22+
}
23+
24+
} // namespace http
25+
26+
} // namespace network
27+
28+
} // namespace boost
29+
30+
#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PATH_IPP_20111204

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct port_wrapper {
1818
operator boost::uint16_t () const;
1919
operator boost::optional<boost::uint16_t> () const;
2020
private:
21-
request_base const & message_;
21+
request_base const & request_;
2222
};
2323

2424
inline port_wrapper const
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204
2+
#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204
3+
4+
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2011 Google, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include <boost/network/protocol/http/message/wrappers/port.hpp>
11+
#include <boost/network/uri/uri.hpp>
12+
13+
namespace boost { namespace network { namespace http {
14+
15+
port_wrapper::port_wrapper(request_base const & request)
16+
: request_(request) {}
17+
18+
port_wrapper::operator boost::uint16_t () const {
19+
uri::uri uri_;
20+
request_.get_uri(uri_);
21+
optional<boost::uint16_t> optional_port = port_us(uri_);
22+
return optional_port ? *optional_port : 80u;
23+
}
24+
25+
port_wrapper::operator optional<boost::uint16_t> () const {
26+
uri::uri uri_;
27+
request_.get_uri(uri_);
28+
return port_us(uri_);
29+
}
30+
31+
} // namespace http
32+
33+
} // namespace network
34+
35+
} // namespace boost
36+
37+
#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_PORT_IPP_20111204
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_IPP_20111204
2+
#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_IPP_20111204
3+
4+
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2011 Google, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include <boost/network/protocol/http/message/wrappers/query.hpp>
11+
#include <boost/network/uri/uri.hpp>
12+
13+
namespace boost { namespace network { namespace http {
14+
15+
query_wrapper::query_wrapper(request_base const & request)
16+
: request_(request) {}
17+
18+
query_wrapper::operator std::string () const {
19+
uri::uri uri_;
20+
request_.get_uri(uri_);
21+
return query(uri_);
22+
}
23+
24+
} // namespace http
25+
26+
} // namespace network
27+
28+
} // namespace boost
29+
30+
#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_QUERY_IPP_20111204

libs/network/src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS})
4747

4848
set(CPP-NETLIB_UTILS_THREAD_POOL_SRCS utils/thread_pool.cpp)
4949
add_library(cppnetlib-utils-thread_pool ${CPP-NETLIB_UTILS_THREAD_POOL_SRCS})
50+
51+
set(CPP-NETLIB_CONSTANTS_SRCS constants.cpp)
52+
add_library(cppnetlib-constants ${CPP-NETLIB_CONSTANTS_SRCS})

libs/network/src/constants.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2011 Dean Michael Berris <dberris@google.com>.
2+
// Copyright 2011 Google, Inc.
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// (See accompanying file LICENSE_1_0.txt or copy at
5+
// http://www.boost.org/LICENSE_1_0.txt)
6+
7+
#ifdef BOOST_NETWORK_NO_LIB
8+
#undef BOOST_NETWORK_NO_LIB
9+
#endif
10+
11+
#include <boost/network/constants.ipp>

libs/network/src/http/client_connections.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010

1111
#include <boost/network/protocol/http/client/connection_manager.ipp>
1212
#include <boost/network/protocol/http/client/client_connection.ipp>
13+
#include <boost/network/protocol/http/impl/access.ipp>

0 commit comments

Comments
 (0)