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

Fix for issue #444 "Unable to compile without OpenSSL"#541

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
deanberris merged 2 commits intocpp-netlib:0.11-develfromcelsius:0.11-devel-fix-disable-ssl
Jul 20, 2015
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
25 changes: 17 additions & 8 deletions.travis.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,14 +6,22 @@ compiler:
- clang

env:
- BOOST_VER=1.54.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release"
- BOOST_VER=1.54.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release"
- BOOST_VER=1.54.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug"
- BOOST_VER=1.54.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug"
- BOOST_VER=1.55.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release"
- BOOST_VER=1.55.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release"
- BOOST_VER=1.55.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug"
- BOOST_VER=1.55.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug"
- BOOST_VER=1.54.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON"
- BOOST_VER=1.54.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON"
- BOOST_VER=1.54.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON"
- BOOST_VER=1.54.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON"
- BOOST_VER=1.55.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON"
- BOOST_VER=1.55.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="ON"
- BOOST_VER=1.55.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON"
- BOOST_VER=1.55.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="ON"
- BOOST_VER=1.54.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF"
- BOOST_VER=1.54.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF"
- BOOST_VER=1.54.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF"
- BOOST_VER=1.54.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF"
- BOOST_VER=1.55.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF"
- BOOST_VER=1.55.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Release" ENABLE_HTTPS="OFF"
- BOOST_VER=1.55.0 BUILD_SHARED_LIBS="ON" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF"
- BOOST_VER=1.55.0 BUILD_SHARED_LIBS="OFF" CMAKE_BUILD_TYPE="Debug" ENABLE_HTTPS="OFF"

before_install:
- if [ "${CXX}" == "g++" ] || [ ${BUILD_SHARED_LIBS} = "OFF" ]; then
Expand All@@ -39,6 +47,7 @@ install:
script:
- cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-DCPP-NETLIB_ENABLE_HTTPS=${ENABLE_HTTPS}
- make
- make test

Expand Down
7 changes: 6 additions & 1 deletionCMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@ option( CPP-NETLIB_BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." OFF
option( CPP-NETLIB_BUILD_TESTS "Build the cpp-netlib project tests." ON)
option( CPP-NETLIB_BUILD_EXPERIMENTS "Build the cpp-netlib project experiments." ON)
option( CPP-NETLIB_BUILD_EXAMPLES "Build the cpp-netlib project examples." ON)
option( CPP-NETLIB_ENABLE_HTTPS "Build cpp-netlib with support for https if OpenSSL is found." ON)

include(GNUInstallDirs)

Expand DownExpand Up@@ -43,7 +44,11 @@ set(Boost_USE_MULTI_THREADED ON)
find_package( Boost 1.54.0
REQUIRED unit_test_framework system regex date_time thread filesystem
program_options chrono atomic )
find_package( OpenSSL )

if (CPP-NETLIB_ENABLE_HTTPS)
find_package( OpenSSL )
endif()

find_package( Threads )
set(CMAKE_VERBOSE_MAKEFILE true)

Expand Down
12 changes: 10 additions & 2 deletionsboost/network/protocol/http/server/async_connection.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -174,14 +174,18 @@ struct async_connection
public:
async_connection(asio::io_service& io_service, Handler& handler,
utils::thread_pool& thread_pool,
boost::shared_ptr<boost::asio::ssl::context> ctx =
boost::shared_ptr<boost::asio::ssl::context>())
boost::shared_ptr<ssl_context> ctx =
boost::shared_ptr<ssl_context>())
: strand(io_service),
handler(handler),
thread_pool_(thread_pool),
headers_buffer(
BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE),
#ifdef BOOST_NETWORK_ENABLE_HTTPS
socket_(io_service, ctx),
#else
socket_(io_service),
#endif
handshake_done(false),
headers_already_sent(false),
headers_in_progress(false) {
Expand DownExpand Up@@ -379,21 +383,25 @@ struct async_connection
}

void read_more(state_t state) {
#ifdef BOOST_NETWORK_ENABLE_HTTPS
if (socket_.is_ssl_enabled() && !handshake_done) {
socket_.async_handshake(
boost::asio::ssl::stream_base::server,
boost::bind(&async_connection::handle_handshake,
async_connection<Tag, Handler>::shared_from_this(),
boost::asio::placeholders::error, state));
} else {
#endif
socket_.async_read_some(
asio::buffer(read_buffer_),
strand.wrap(
boost::bind(&async_connection<Tag, Handler>::handle_read_data,
async_connection<Tag, Handler>::shared_from_this(),
state, boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred)));
#ifdef BOOST_NETWORK_ENABLE_HTTPS
}
#endif
}

void handle_read_data(state_t state, boost::system::error_code const& ec,
Expand Down
14 changes: 13 additions & 1 deletionboost/network/protocol/http/server/async_server.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -89,7 +89,7 @@ struct async_server_base : server_storage_base, socket_options_base {
boost::mutex listening_mutex_;
boost::mutex stopping_mutex_;
bool listening;
boost::shared_ptr<boost::asio::ssl::context> ctx_;
boost::shared_ptr<ssl_context> ctx_;

void handle_stop() {
scoped_mutex_lock stopping_lock(stopping_mutex_);
Expand All@@ -111,12 +111,20 @@ struct async_server_base : server_storage_base, socket_options_base {
BOOST_NETWORK_MESSAGE("Error accepting connection, reason: " << ec);
}

#ifdef BOOST_NETWORK_ENABLE_HTTPS
socket_options_base::socket_options(new_connection->socket().next_layer());
#else
socket_options_base::socket_options(new_connection->socket());
#endif

new_connection->start();
new_connection.reset(new connection(service_, handler, *thread_pool, ctx_));
acceptor.async_accept(
#ifdef BOOST_NETWORK_ENABLE_HTTPS
new_connection->socket().next_layer(),
#else
new_connection->socket(),
#endif
boost::bind(&async_server_base<Tag, Handler>::handle_accept, this,
boost::asio::placeholders::error));
}
Expand DownExpand Up@@ -155,7 +163,11 @@ struct async_server_base : server_storage_base, socket_options_base {
}
new_connection.reset(new connection(service_, handler, *thread_pool, ctx_));
acceptor.async_accept(
#ifdef BOOST_NETWORK_ENABLE_HTTPS
new_connection->socket().next_layer(),
#else
new_connection->socket(),
#endif
boost::bind(&async_server_base<Tag, Handler>::handle_accept, this,
boost::asio::placeholders::error));
listening = true;
Expand Down
8 changes: 4 additions & 4 deletionsboost/network/protocol/http/server/options.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@

#include <boost/asio/io_service.hpp>
#include <boost/asio/socket_base.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/network/protocol/stream_handler.hpp>
#include <boost/network/traits/string.hpp>
#include <boost/network/utils/thread_pool.hpp>
#include <boost/optional.hpp>
Expand DownExpand Up@@ -81,7 +81,7 @@ struct server_options {
swap(context_, other.context_);
}

server_options &context(boost::shared_ptr<boost::asio::ssl::context> v) {
server_options &context(boost::shared_ptr<ssl_context> v) {
context_ = v;
return *this;
}
Expand DownExpand Up@@ -172,7 +172,7 @@ struct server_options {
boost::shared_ptr<utils::thread_pool> thread_pool() const {
return thread_pool_;
}
boost::shared_ptr<boost::asio::ssl::context> context() const {
boost::shared_ptr<ssl_context> context() const {
return context_;
}

Expand All@@ -194,7 +194,7 @@ struct server_options {
boost::optional<boost::asio::socket_base::send_low_watermark>
send_low_watermark_;
boost::shared_ptr<utils::thread_pool> thread_pool_;
boost::shared_ptr<boost::asio::ssl::context> context_;
boost::shared_ptr<ssl_context> context_;
};

template <class Tag, class Handler>
Expand Down
16 changes: 13 additions & 3 deletionsboost/network/protocol/stream_handler.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,9 @@
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio.hpp>
#ifdef BOOST_NETWORK_ENABLE_HTTPS
#include <boost/asio/ssl.hpp>
#endif
#include <boost/asio/detail/push_options.hpp>
#include <boost/asio/detail/config.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
Expand All@@ -28,9 +30,16 @@
namespace boost {
namespace network {

typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ssl_socket;
typedef boost::asio::ip::tcp::socket tcp_socket;

#ifndef BOOST_NETWORK_ENABLE_HTTPS
typedef tcp_socket stream_handler;
typedef void ssl_context;
#else

typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ssl_socket;
typedef boost::asio::ssl::context ssl_context;

struct stream_handler {
public:
stream_handler(boost::shared_ptr<tcp_socket> socket)
Expand All@@ -42,8 +51,8 @@ struct stream_handler {
: ssl_sock_(socket), ssl_enabled(true) {}

stream_handler(boost::asio::io_service& io,
boost::shared_ptr<boost::asio::ssl::context> ctx =
boost::shared_ptr<boost::asio::ssl::context>()) {
boost::shared_ptr<ssl_context> ctx =
boost::shared_ptr<ssl_context>()) {
tcp_sock_ = boost::make_shared<tcp_socket>(boost::ref(io));
ssl_enabled = false;
if (ctx) {
Expand DownExpand Up@@ -172,6 +181,7 @@ struct stream_handler {
boost::shared_ptr<ssl_socket> ssl_sock_;
bool ssl_enabled;
};
#endif
}
}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp