Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Put boost asio back in again#668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletionsCMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,7 +45,7 @@ add_definitions(-DBOOST_TEST_DYN_LINK)
# Always use multi-threaded Boost libraries.
set(Boost_USE_MULTI_THREADEDON)

find_package(Boost 1.57.0 REQUIRED)
find_package(Boost 1.57.0 REQUIRED COMPONENTSsystem)

if (CPP-NETLIB_ENABLE_HTTPS)
find_package( OpenSSL )
Expand DownExpand Up@@ -97,9 +97,9 @@ if (Boost_FOUND)
endif(WIN32)
include_directories(${Boost_INCLUDE_DIRS})

# Asio
add_definitions(-DASIO_STANDALONE)
include_directories(deps/asio/asio/include)
##Asio
#add_definitions(-DASIO_STANDALONE)
#include_directories(deps/asio/asio/include)

enable_testing()
add_subdirectory(libs/network/src)
Expand Down
20 changes: 10 additions & 10 deletionsboost/network/protocol/http/client/async_impl.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,8 +11,8 @@
#include <thread>
#include <memory>
#include <functional>
#include <asio/io_service.hpp>
#include <asio/strand.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/strand.hpp>
#include <boost/network/protocol/http/traits/connection_policy.hpp>

namespace boost {
Expand All@@ -32,14 +32,14 @@ struct async_client
typedef typename string<Tag>::type string_type;

typedef std::function<void(boost::iterator_range<char const*> const&,
std::error_code const&)>
boost::system::error_code const&)>
body_callback_function_type;

typedef std::function<bool(string_type&)> body_generator_function_type;

async_client(bool cache_resolved, bool follow_redirect,
bool always_verify_peer, int timeout,
std::shared_ptr<::asio::io_service> service,
std::shared_ptr<boost::asio::io_service> service,
optional<string_type> certificate_filename,
optional<string_type> verify_path,
optional<string_type> certificate_file,
Expand All@@ -48,10 +48,10 @@ struct async_client
optional<string_type> sni_hostname, long ssl_options)
: connection_base(cache_resolved, follow_redirect, timeout),
service_ptr(service.get() ? service
: std::make_shared<::asio::io_service>()),
: std::make_shared<boost::asio::io_service>()),
service_(*service_ptr),
resolver_(service_),
sentinel_(new ::asio::io_service::work(service_)),
sentinel_(newboost::asio::io_service::work(service_)),
certificate_filename_(std::move(certificate_filename)),
verify_path_(std::move(verify_path)),
certificate_file_(std::move(certificate_file)),
Expand All@@ -61,7 +61,7 @@ struct async_client
ssl_options_(ssl_options),
always_verify_peer_(always_verify_peer) {
connection_base::resolver_strand_.reset(
new ::asio::io_service::strand(service_));
newboost::asio::io_service::strand(service_));
if (!service)
lifetime_thread_.reset(new std::thread([this]() { service_.run(); }));
}
Expand DownExpand Up@@ -89,10 +89,10 @@ struct async_client
generator);
}

std::shared_ptr<::asio::io_service> service_ptr;
::asio::io_service& service_;
std::shared_ptr<boost::asio::io_service> service_ptr;
boost::asio::io_service& service_;
resolver_type resolver_;
std::shared_ptr<::asio::io_service::work> sentinel_;
std::shared_ptr<boost::asio::io_service::work> sentinel_;
std::shared_ptr<std::thread> lifetime_thread_;
optional<string_type> certificate_filename_;
optional<string_type> verify_path_;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ struct async_connection_base {
typedef basic_response<Tag> response;
typedeftypename std::array<typename char_<Tag>::type,1024>::const_iterator const_iterator;
typedef iterator_range<const_iterator> char_const_range;
typedef std::function<void(char_const_rangeconst &,std::error_codeconst &)>
typedef std::function<void(char_const_rangeconst &,boost::system::error_codeconst &)>
body_callback_function_type;
typedef std::function<bool(string_type &)> body_generator_function_type;
typedef std::shared_ptr<this_type> connection_ptr;
Expand Down
98 changes: 49 additions & 49 deletionsboost/network/protocol/http/client/connection/async_normal.hpp
View file
Open in desktop

Large diffs are not rendered by default.

View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -139,7 +139,7 @@ struct http_async_protocol_handler {
std::end(result_range));
part_begin = part.begin();
delegate_->read_some(
::asio::mutable_buffers_1(part.data(), part.size()),
boost::asio::mutable_buffers_1(part.data(), part.size()),
callback);
}
return parsed_ok;
Expand DownExpand Up@@ -185,7 +185,7 @@ struct http_async_protocol_handler {
std::end(result_range));
part_begin = part.begin();
delegate_->read_some(
::asio::mutable_buffers_1(part.data(), part.size()),
boost::asio::mutable_buffers_1(part.data(), part.size()),
callback);
}
return parsed_ok;
Expand DownExpand Up@@ -230,7 +230,7 @@ struct http_async_protocol_handler {
std::end(result_range));
part_begin = part.begin();
delegate_->read_some(
::asio::mutable_buffers_1(part.data(), part.size()),
boost::asio::mutable_buffers_1(part.data(), part.size()),
callback);
}
return parsed_ok;
Expand DownExpand Up@@ -317,7 +317,7 @@ struct http_async_protocol_handler {
std::end(result_range));
part_begin = part.begin();
delegate_->read_some(
::asio::mutable_buffers_1(part.data(), part.size()),
boost::asio::mutable_buffers_1(part.data(), part.size()),
callback);
}
return std::make_tuple(
Expand All@@ -331,7 +331,7 @@ struct http_async_protocol_handler {
partial_parsed.append(part_begin, bytes);
part_begin = part.begin();
delegate_->read_some(
::asio::mutable_buffers_1(part.data(), part.size()), callback);
boost::asio::mutable_buffers_1(part.data(), part.size()), callback);
}

typedef response_parser<Tag> response_parser_type;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,24 +9,24 @@

#include <cstdint>
#include <functional>
#include <asio/ip/tcp.hpp>
#include <asio/streambuf.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/streambuf.hpp>

namespace boost {
namespace network {
namespace http {
namespace impl {

struct connection_delegate {
virtual void connect(::asio::ip::tcp::endpoint &endpoint, std::string host,
virtual void connect(boost::asio::ip::tcp::endpoint &endpoint, std::string host,
std::uint16_t source_port,
std::function<void(std::error_code const &)> handler) = 0;
std::function<void(boost::system::error_code const &)> handler) = 0;
virtual void write(
::asio::streambuf &command_streambuf,
std::function<void(std::error_code const &, size_t)> handler) = 0;
boost::asio::streambuf &command_streambuf,
std::function<void(boost::system::error_code const &, size_t)> handler) = 0;
virtual void read_some(
::asio::mutable_buffers_1 const &read_buffer,
std::function<void(std::error_code const &, size_t)> handler) = 0;
boost::asio::mutable_buffers_1 const &read_buffer,
std::function<void(boost::system::error_code const &, size_t)> handler) = 0;
virtual void disconnect() = 0;
virtual ~connection_delegate() = default;
};
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ struct connection_delegate_factory {
// This is the factory method that actually returns the delegate instance.
// TODO(dberris): Support passing in proxy settings when crafting connections.
static connection_delegate_ptr new_connection_delegate(
::asio::io_service& service, bool https, bool always_verify_peer,
boost::asio::io_service& service, bool https, bool always_verify_peer,
optional<string_type> certificate_filename,
optional<string_type> verify_path, optional<string_type> certificate_file,
optional<string_type> private_key_file, optional<string_type> ciphers,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,10 +10,10 @@
#include <memory>
#include <cstdint>
#include <functional>
#include <asio/io_service.hpp>
#include <asio/ip/tcp.hpp>
#include <asio/placeholders.hpp>
#include <asio/streambuf.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/placeholders.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/network/protocol/http/client/connection/connection_delegate.hpp>

namespace boost {
Expand All@@ -22,16 +22,16 @@ namespace http {
namespace impl {

struct normal_delegate : connection_delegate {
explicit normal_delegate(::asio::io_service &service);
explicit normal_delegate(boost::asio::io_service &service);

void connect(::asio::ip::tcp::endpoint &endpoint, std::string host,
void connect(boost::asio::ip::tcp::endpoint &endpoint, std::string host,
std::uint16_t source_port,
std::function<void(std::error_code const &)> handler) override;
void write(::asio::streambuf &command_streambuf,
std::function<void(std::error_code const &, size_t)> handler)
std::function<void(boost::system::error_code const &)> handler) override;
void write(boost::asio::streambuf &command_streambuf,
std::function<void(boost::system::error_code const &, size_t)> handler)
override;
void read_some(::asio::mutable_buffers_1 const &read_buffer,
std::function<void(std::error_code const &, size_t)> handler)
void read_some(boost::asio::mutable_buffers_1 const &read_buffer,
std::function<void(boost::system::error_code const &, size_t)> handler)
override;
void disconnect() override;
~normal_delegate() override = default;
Expand All@@ -40,8 +40,8 @@ struct normal_delegate : connection_delegate {
normal_delegate &operator=(normal_delegate) = delete;

private:
::asio::io_service &service_;
std::unique_ptr<::asio::ip::tcp::socket> socket_;
boost::asio::io_service &service_;
std::unique_ptr<boost::asio::ip::tcp::socket> socket_;
};

} // namespace impl
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,46 +9,46 @@

#include <cstdint>
#include <functional>
#include <asio/ip/tcp.hpp>
#include <asio/streambuf.hpp>
#include <asio/write.hpp>
#include <asio/buffer.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/asio/write.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/network/protocol/http/client/connection/normal_delegate.hpp>

boost::network::http::impl::normal_delegate::normal_delegate(
::asio::io_service &service)
boost::asio::io_service &service)
: service_(service) {}

void boost::network::http::impl::normal_delegate::connect(
::asio::ip::tcp::endpoint &endpoint, std::string host,
boost::asio::ip::tcp::endpoint &endpoint, std::string host,
std::uint16_t source_port,
std::function<void(std::error_code const &)> handler) {
std::function<void(boost::system::error_code const &)> handler) {

// TODO(dberris): review parameter necessity.
(void)host;

socket_.reset(new ::asio::ip::tcp::socket(
socket_.reset(newboost::asio::ip::tcp::socket(
service_,
::asio::ip::tcp::endpoint(::asio::ip::address(), source_port)));
boost::asio::ip::tcp::endpoint(boost::asio::ip::address(), source_port)));
socket_->async_connect(endpoint, handler);
}

void boost::network::http::impl::normal_delegate::write(
::asio::streambuf &command_streambuf,
std::function<void(std::error_code const &, size_t)> handler) {
::asio::async_write(*socket_, command_streambuf, handler);
boost::asio::streambuf &command_streambuf,
std::function<void(boost::system::error_code const &, size_t)> handler) {
boost::asio::async_write(*socket_, command_streambuf, handler);
}

void boost::network::http::impl::normal_delegate::read_some(
::asio::mutable_buffers_1 const &read_buffer,
std::function<void(std::error_code const &, size_t)> handler) {
boost::asio::mutable_buffers_1 const &read_buffer,
std::function<void(boost::system::error_code const &, size_t)> handler) {
socket_->async_read_some(read_buffer, handler);
}

void boost::network::http::impl::normal_delegate::disconnect() {
if (socket_.get() && socket_->is_open()) {
std::error_code ignored;
socket_->shutdown(::asio::ip::tcp::socket::shutdown_both, ignored);
boost::system::error_code ignored;
socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored);
if (!ignored) {
socket_->close(ignored);
}
Expand Down
30 changes: 15 additions & 15 deletionsboost/network/protocol/http/client/connection/ssl_delegate.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,8 @@
#include <memory>
#include <cstdint>
#include <functional>
#include <asio/io_service.hpp>
#include <asio/ssl.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/network/protocol/http/client/connection/connection_delegate.hpp>
#include <boost/network/support/is_default_string.hpp>
#include <boost/network/support/is_default_wstring.hpp>
Expand All@@ -24,45 +24,45 @@ namespace impl {

struct ssl_delegate : public connection_delegate,
public std::enable_shared_from_this<ssl_delegate> {
ssl_delegate(::asio::io_service &service, bool always_verify_peer,
ssl_delegate(boost::asio::io_service &service, bool always_verify_peer,
optional<std::string> certificate_filename,
optional<std::string> verify_path,
optional<std::string> certificate_file,
optional<std::string> private_key_file,
optional<std::string> ciphers,
optional<std::string> sni_hostname, long ssl_options);

void connect(::asio::ip::tcp::endpoint &endpoint, std::string host,
void connect(boost::asio::ip::tcp::endpoint &endpoint, std::string host,
std::uint16_t source_port,
std::function<void(std::error_code const &)> handler) override;
std::function<void(boost::system::error_code const &)> handler) override;
void write(
::asio::streambuf &command_streambuf,
std::function<void(std::error_code const &, size_t)> handler) override;
boost::asio::streambuf &command_streambuf,
std::function<void(boost::system::error_code const &, size_t)> handler) override;
void read_some(
::asio::mutable_buffers_1 const &read_buffer,
std::function<void(std::error_code const &, size_t)> handler) override;
boost::asio::mutable_buffers_1 const &read_buffer,
std::function<void(boost::system::error_code const &, size_t)> handler) override;
void disconnect() override;
~ssl_delegate() override;

private:
::asio::io_service &service_;
boost::asio::io_service &service_;
optional<std::string> certificate_filename_;
optional<std::string> verify_path_;
optional<std::string> certificate_file_;
optional<std::string> private_key_file_;
optional<std::string> ciphers_;
optional<std::string> sni_hostname_;
long ssl_options_;
std::unique_ptr<::asio::ssl::context> context_;
std::unique_ptr<::asio::ip::tcp::socket> tcp_socket_;
std::unique_ptr<::asio::ssl::stream<::asio::ip::tcp::socket &> > socket_;
std::unique_ptr<boost::asio::ssl::context> context_;
std::unique_ptr<boost::asio::ip::tcp::socket> tcp_socket_;
std::unique_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket &> > socket_;
bool always_verify_peer_;

ssl_delegate(ssl_delegate const &); // = delete
ssl_delegate &operator=(ssl_delegate); // = delete

void handle_connected(std::error_code const &ec,
std::function<void(std::error_code const &)> handler);
void handle_connected(boost::system::error_code const &ec,
std::function<void(boost::system::error_code const &)> handler);
};

} // namespace impl
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp