Skip to content

Commit 0c77811

Browse files
committed
Added headers which move boost::network::http::* types into network::http. Updated examples accordingly.
1 parent 1338fb4 commit 0c77811

File tree

16 files changed

+90
-146
lines changed

16 files changed

+90
-146
lines changed

include/network/http/client.hpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) Glyn Matthews 2012.
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+
#ifndef __NETWORK_HTTP_CLIENT_INC__
7+
# define __NETWORK_HTTP_CLIENT_INC__
8+
9+
# include <boost/network/protocol/http/client.hpp>
10+
# include <network/http/request.hpp>
11+
# include <network/http/response.hpp>
12+
# include <network/http/errors.hpp>
13+
14+
namespace network {
15+
using boost::network::header;
16+
17+
namespace http {
18+
using boost::network::http::client;
19+
} // namespace http
20+
} // namespace network
21+
22+
#endif // __NETWORK_HTTP_CLIENT_INC__

include/network/http/errors.hpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Glyn Matthews 2012.
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+
#ifndef __NETWORK_HTTP_ERRORS_INC__
7+
# define __NETWORK_HTTP_ERRORS_INC__
8+
9+
# include <boost/network/protocol/http/errors.hpp>
10+
11+
namespace network {
12+
namespace http {
13+
namespace errors {
14+
using boost::network::http::errors::connection_timeout;
15+
} // namespace errors
16+
} // namespace http
17+
} // namespace network
18+
19+
#endif // __NETWORK_HTTP_ERRORS_INC__

include/network/http/request.hpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Glyn Matthews 2012.
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+
#ifndef __NETWORK_HTTP_REQUEST_INC__
7+
# define __NETWORK_HTTP_REQUEST_INC__
8+
9+
# include <boost/network/protocol/http/request.hpp>
10+
11+
namespace network {
12+
namespace http {
13+
using boost::network::http::request;
14+
} // namespace http
15+
} // namespace network
16+
17+
#endif // __NETWORK_HTTP_REQUEST_INC__

include/network/http/response.hpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Glyn Matthews 2012.
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+
#ifndef __NETWORK_HTTP_RESPONSE_INC__
7+
# define __NETWORK_HTTP_RESPONSE_INC__
8+
9+
# include <boost/network/protocol/http/response.hpp>
10+
11+
namespace network {
12+
namespace http {
13+
using boost::network::http::response;
14+
} // namespace http
15+
} // namespace network
16+
17+
#endif // __NETWORK_HTTP_RESPONSE_INC__

libs/network/example/CMakeLists.txt

-16
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ if (OPENSSL_FOUND)
1010
endif (OPENSSL_FOUND)
1111

1212
add_executable(uri_builder uri_builder.cpp)
13-
#add_executable(http_client http_client.cpp)
1413
add_executable(simple_wget simple_wget.cpp)
1514
add_executable(atom_reader atom/atom.cpp atom/main.cpp)
1615
add_executable(rss_reader rss/rss.cpp rss/main.cpp)
@@ -41,19 +40,6 @@ target_link_libraries(uri_builder
4140
${CMAKE_THREAD_LIBS_INIT}
4241
cppnetlib-uri)
4342

44-
#target_link_libraries(http_client
45-
# ${BOOST_CLIENT_LIBS}
46-
# ${CMAKE_THREAD_LIBS_INIT}
47-
# cppnetlib-uri
48-
# cppnetlib-message
49-
# cppnetlib-message-directives
50-
# cppnetlib-message-wrappers
51-
# cppnetlib-http-message-wrappers
52-
# cppnetlib-http-message
53-
# cppnetlib-constants
54-
# cppnetlib-http-client
55-
# cppnetlib-http-client-connections)
56-
5743
target_link_libraries(simple_wget
5844
${BOOST_CLIENT_LIBS}
5945
${CMAKE_THREAD_LIBS_INIT}
@@ -126,7 +112,6 @@ target_link_libraries(hello_world_client
126112

127113
if (OPENSSL_FOUND)
128114
target_link_libraries(uri_builder ${OPENSSL_LIBRARIES})
129-
#target_link_libraries(http_client ${OPENSSL_LIBRARIES})
130115
target_link_libraries(simple_wget ${OPENSSL_LIBRARIES})
131116
target_link_libraries(atom_reader ${OPENSSL_LIBRARIES})
132117
target_link_libraries(rss_reader ${OPENSSL_LIBRARIES})
@@ -144,7 +129,6 @@ endif (OPENSSL_FOUND)
144129
#endif (UNIX)
145130

146131
set_target_properties(uri_builder PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
147-
#set_target_properties(http_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
148132
set_target_properties(simple_wget PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
149133
set_target_properties(atom_reader PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
150134
set_target_properties(rss_reader PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)

libs/network/example/Jamfile.v2

-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ project network_test :
2323

2424
exe uri : uri.cpp /cpp-netlib//cppnetlib-uri ;
2525

26-
exe http_client : http_client.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-client-connections ;
27-
28-
exe http_client1 : http_client1.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-client-connections ;
2926

3027
exe simple_wget : simple_wget.cpp /cpp-netlib//cppnetlib-uri /cpp-netlib//cppnetlib-client-connections ;
3128

libs/network/example/atom/atom.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <stdexcept>
1010
#include <cassert>
1111

12-
13-
namespace boost {
1412
namespace network {
1513
namespace atom {
1614
feed::feed(const http::client::response &response) {
@@ -94,4 +92,3 @@ feed::feed(const http::client::response &response) {
9492
}
9593
} // namespace atom
9694
} // namespace network
97-
} // namespace boost

libs/network/example/atom/atom.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
# include <string>
1111
# include <vector>
12-
# include <boost/network/protocol/http.hpp>
12+
# include <network/http/client.hpp>
1313

1414

15-
namespace boost {
1615
namespace network {
1716
namespace atom {
1817
class entry {
@@ -172,6 +171,5 @@ class feed {
172171
};
173172
} // namespace atom
174173
} // namespace network
175-
} // namespace boost
176174

177175
#endif // ___ATOM_INC__

libs/network/example/atom/main.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
// Copyright (c) Glyn Matthews 2011.
1+
// Copyright (c) Glyn Matthews 2011, 2012.
22
// Distributed under the Boost Software License, Version 1.0.
33
// (See accompanying file LICENSE_1_0.txt or copy at
44
// http://www.boost.org/LICENSE_1_0.txt)
55

66

77
#include "atom.hpp"
8-
#include <boost/network/protocol/http/client.hpp>
8+
#include <network/http/client.hpp>
99
#include <boost/foreach.hpp>
1010
#include <iostream>
1111

1212
int main(int argc, char * argv[]) {
13-
using namespace boost::network;
13+
namespace http = network::http;
14+
namespace atom = network::atom;
1415

1516
if (argc != 2) {
1617
std::cout << "Usage: " << argv[0] << " <url>" << std::endl;
@@ -20,7 +21,7 @@ int main(int argc, char * argv[]) {
2021
try {
2122
http::client client;
2223
http::client::request request(argv[1]);
23-
request << header("Connection", "close");
24+
request << network::header("Connection", "close");
2425
http::client::response response = client.get(request);
2526
atom::feed feed(response);
2627

libs/network/example/http_client.cpp

-81
This file was deleted.

libs/network/example/http_client1.cpp

-23
This file was deleted.

libs/network/example/rss/main.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66

77
#include "rss.hpp"
8-
#include <boost/network/protocol/http/client.hpp>
8+
#include <network/http/client.hpp>
99
#include <boost/foreach.hpp>
1010
#include <iostream>
1111

1212
int main(int argc, char * argv[]) {
13-
using namespace boost::network;
13+
namespace http = network::http;
14+
namespace rss = network::rss;
1415

1516
if (argc != 2) {
1617
std::cout << "Usage: " << argv[0] << " <url>" << std::endl;
@@ -20,7 +21,7 @@ int main(int argc, char * argv[]) {
2021
try {
2122
http::client client;
2223
http::client::request request(argv[1]);
23-
request << header("Connection", "close");
24+
request << network::header("Connection", "close");
2425
http::client::response response = client.get(request);
2526
rss::channel channel(response);
2627

libs/network/example/rss/rss.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <stdexcept>
1010
#include <cassert>
1111

12-
13-
namespace boost {
1412
namespace network {
1513
namespace rss {
1614
channel::channel(const http::client::response &response) {
@@ -72,4 +70,3 @@ channel::channel(const http::client::response &response) {
7270
}
7371
} // namespace rss
7472
} // namespace network
75-
} // namespace boost

libs/network/example/rss/rss.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
# include <string>
1111
# include <vector>
12-
# include <boost/network/protocol/http.hpp>
12+
# include <network/http/client.hpp>
1313

1414

15-
namespace boost {
1615
namespace network {
1716
namespace rss {
1817
class item {
@@ -107,6 +106,5 @@ class channel {
107106
};
108107
} // namespace rss
109108
} // namespace network
110-
} // namespace boost
111109

112110
#endif // ___RSS_INC__

libs/network/example/simple_wget.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
*/
1515

1616

17-
#include <boost/network/protocol/http/client.hpp>
17+
#include <network/http/client.hpp>
1818
#include <network/uri.hpp>
1919
#include <string>
2020
#include <fstream>
2121
#include <iostream>
2222

2323

24-
namespace http = boost::network::http;
24+
namespace http = network::http;
2525

2626

2727
namespace {

libs/network/example/twitter/search.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// http://www.boost.org/LICENSE_1_0.txt)
55

66
#include <network/uri/uri.hpp>
7-
#include <boost/network/protocol/http/client.hpp>
7+
#include <network/http/client.hpp>
88
#include "rapidjson/rapidjson.h"
99
#include "rapidjson/document.h"
1010
#include <iostream>
@@ -14,7 +14,7 @@
1414
// https://dev.twitter.com/docs/using-search
1515

1616
int main(int argc, char *argv[]) {
17-
namespace http = boost::network::http;
17+
namespace http = network::http;
1818
using namespace rapidjson;
1919

2020
if (argc != 2) {

0 commit comments

Comments
 (0)