Skip to content

Commit 348ed84

Browse files
committed
Merge branch 'master' of github.com:cpp-netlib/cpp-netlib
Conflicts: include/network/protocol/http/message/wrappers/status_message.hpp include/network/protocol/http/message/wrappers/version.hpp libs/network/example/atom/atom.hpp libs/network/example/atom/main.cpp libs/network/example/http_client.cpp libs/network/example/http_client1.cpp libs/network/example/rss/main.cpp libs/network/example/rss/rss.hpp libs/network/example/simple_wget.cpp libs/network/example/twitter/search.cpp
2 parents 9d69d71 + a4dabd5 commit 348ed84

38 files changed

+467
-232
lines changed

CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
cmake_minimum_required(VERSION 2.8)
88
project(CPP-NETLIB)
99
set(Boost_USE_STATIC_LIBS ON)
10-
set(Boost_USE_MULTI_THREADED ON)
11-
find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread filesystem program_options )
10+
set(Boost_USE_MULTITHREADED ON)
11+
find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread chrono filesystem program_options )
1212
find_package( OpenSSL )
1313
find_package( Threads )
1414
set(CMAKE_VERBOSE_MAKEFILE true)
@@ -26,10 +26,12 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
2626
CHECK_CXX_COMPILER_FLAG(-std=c++0x HAVE_STD0X)
2727
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
2828

29-
if (NOT HAVE_STD0X)
30-
if (NOT HAVE_STD11)
31-
message(FATAL_ERROR "No advanced standard C++ support (-std=c++0x and -std=c++11 not defined).")
32-
endif()
29+
if (HAVE_STD11)
30+
set(CMAKE_CXX_FLAGS -std=c++11)
31+
elseif (HAVE_STD0X)
32+
set(CMAKE_CXX_FLAGS -std=c++0x)
33+
else()
34+
message(FATAL_ERROR "No advanced standard C++ support (-std=c++0x and -std=c++11 not defined).")
3335
endif()
3436
endif()
3537

include/network/http/client.hpp

Lines changed: 22 additions & 0 deletions
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

Lines changed: 19 additions & 0 deletions
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

Lines changed: 17 additions & 0 deletions
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

Lines changed: 17 additions & 0 deletions
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__

include/network/protocol/http/algorithms/linearize.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,8 @@ namespace boost { namespace network { namespace http {
152152
boost::copy(crlf, oi);
153153
}
154154
boost::copy(crlf, oi);
155-
boost::iterator_range<std::string::const_iterator> body_data =
156-
boost::network::body(request);
157-
return boost::copy(body_data, oi);
155+
auto body_data = boost::network::body(request);
156+
return std::copy(body_data.begin(), body_data.end(), oi);
158157
}
159158

160159
} /* http */

include/network/protocol/http/client/client_connection.ipp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ client_connection * client_connection::clone() const {
2222
BOOST_NETWORK_MESSAGE("client_connection::clone()");
2323
// For exposition only.
2424
BOOST_ASSERT(false && "This should not ever be called.");
25+
return 0;
2526
}
2627

2728

include/network/protocol/http/client/connection/sync_base.hpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,20 @@ namespace boost { namespace network { namespace http { namespace impl {
148148
throw boost::system::system_error(error);
149149
} else {
150150
bool stopping_inner = false;
151+
std::istreambuf_iterator<char> eos;
152+
std::istreambuf_iterator<char> stream_iterator0(&response_buffer);
153+
for (; chunk_size > 0 && stream_iterator0 != eos; --chunk_size)
154+
body_stream << *stream_iterator0++;
155+
151156
do {
152-
std::size_t chunk_bytes_read = read(socket_, response_buffer, boost::asio::transfer_at_least(chunk_size), error);
153-
if (chunk_bytes_read == 0) {
154-
if (error != boost::asio::error::eof) throw boost::system::system_error(error);
155-
stopping_inner = true;
157+
if (chunk_size != 0) {
158+
std::size_t chunk_bytes_read = read(socket_, response_buffer, boost::asio::transfer_at_least(chunk_size), error);
159+
if (chunk_bytes_read == 0) {
160+
if (error != boost::asio::error::eof) throw boost::system::system_error(error);
161+
stopping_inner = true;
162+
}
156163
}
157164

158-
std::istreambuf_iterator<char> eos;
159165
std::istreambuf_iterator<char> stream_iterator(&response_buffer);
160166
for (; chunk_size > 0 && stream_iterator != eos; --chunk_size)
161167
body_stream << *stream_iterator++;

include/network/protocol/http/message/wrappers/status_message.hpp

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

11+
#include <boost/optional.hpp>
12+
#include <boost/network/protocol/http/response/response_base.hpp>
1113
#include <network/protocol/http/response/response_base.hpp>
1214

1315
namespace boost { namespace network { namespace http {

include/network/protocol/http/message/wrappers/version.hpp

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

11+
#include <boost/optional.hpp>
12+
#include <boost/network/protocol/http/response/response_base.hpp>
1113
#include <network/protocol/http/response/response_base.hpp>
1214

1315
namespace boost { namespace network { namespace http {

0 commit comments

Comments
 (0)