Skip to content

Commit

Permalink
Added SSL connection to the HTTP client. Untested.
Browse files Browse the repository at this point in the history
  • Loading branch information
glynos committed Dec 22, 2013
1 parent 8ebb168 commit f86503f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 55 deletions.
60 changes: 6 additions & 54 deletions http/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Copyright 2012 A. Joel Lamotte (mjklaim@gmail.com)
# Copyright 2011 Google, Inc.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)


include_directories(
Expand Down Expand Up @@ -39,22 +39,6 @@ if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
add_library(cppnetlib-http-message-wrappers ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS})
endif()

#set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS
# http/client_connections.cpp
# http/simple_connection_manager.cpp
# http/simple_connection_factory.cpp
# http/connection_delegate_factory.cpp
# http/client_resolver_delegate.cpp
# http/client_resolver_delegate_factory.cpp
# http/client_connection_delegates.cpp
# http/client_connection_factory.cpp
# http/client_async_resolver.cpp
# http/client_connection_normal.cpp)
#
#if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
# add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS})
#endif()

set(CPP-NETLIB_CONSTANTS_SRCS
constants.cpp)

Expand All @@ -72,37 +56,7 @@ if (NOT CPP-NETLIB_BUILD_SINGLE_LIB)
add_library(cppnetlib-http-server ${CPP-NETLIB_HTTP_SERVER_SRCS})
endif()

#set(CPP-NETLIB_HTTP_CLIENT_SRCS
# http/client.cpp)
#
#if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
# add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS})
# add_dependencies(cppnetlib-http-client
# ${CPP-NETLIB_LOGGING_LIB}
# cppnetlib-constants
# cppnetlib-uri
# cppnetlib-message
# cppnetlib-message-wrappers
# cppnetlib-message-directives
# cppnetlib-http-message
# cppnetlib-http-message-wrappers
# cppnetlib-http-client-connections
# )
# target_link_libraries(cppnetlib-http-client
# ${Boost_LIBRARIES}
# ${CPP-NETLIB_LOGGING_LIB}
# cppnetlib-constants
# cppnetlib-uri
# cppnetlib-message
# cppnetlib-message-wrappers
# cppnetlib-message-directives
# cppnetlib-http-message
# cppnetlib-http-message-wrappers
# cppnetlib-http-client-connections
# )
#endif()


# HTTP client
set(CPP-NETLIB_HTTP_V2_CLIENT_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/http/v2/client/client.cpp
${CMAKE_CURRENT_SOURCE_DIR}/http/v2/client/client_errors.cpp
Expand All @@ -115,23 +69,21 @@ target_link_libraries(network-http-v2-client
${Boost_LIBRARIES}
network-uri
)
if (OPENSSL_FOUND)
target_link_libraries(network-http-v2-client ${OPENSSL_LIBRARIES})
endif()

# prepend current directory to make paths absolute
prependToElements( "${CMAKE_CURRENT_SOURCE_DIR}/"
CPP-NETLIB_HTTP_MESSAGE_SRCS
CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS
# CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS
CPP-NETLIB_CONSTANTS_SRCS
CPP-NETLIB_HTTP_SERVER_SRCS
# CPP-NETLIB_HTTP_CLIENT_SRCS
CPP-NETLIB_HTTP_V2_CLIENT_SRCS )


# propagate sources to parent directory for one-lib-build
set(CPP-NETLIB_HTTP_MESSAGE_SRCS ${CPP-NETLIB_HTTP_MESSAGE_SRCS} PARENT_SCOPE)
set(CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS} PARENT_SCOPE)
#set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS} PARENT_SCOPE)
#set(CPP-NETLIB_HTTP_CLIENT_SRCS ${CPP-NETLIB_HTTP_CLIENT_SRCS} PARENT_SCOPE)
set(CPP-NETLIB_HTTP_SERVER_SRCS ${CPP-NETLIB_HTTP_SERVER_SRCS} PARENT_SCOPE)
set(CPP-NETLIB_CONSTANTS_SRCS ${CPP-NETLIB_CONSTANTS_SRCS} PARENT_SCOPE)
set(CPP-NETLIB_HTTP_V2_CLIENT_SRCS ${CPP-NETLIB_HTTP_V2_CLIENT_SRCS} PARENT SCOPE)
9 changes: 8 additions & 1 deletion http/src/http/v2/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <network/http/v2/client/response.hpp>
#include <network/http/v2/client/connection/tcp_resolver.hpp>
#include <network/http/v2/client/connection/normal_connection.hpp>
#include <network/http/v2/client/connection/ssl_connection.hpp>

namespace network {
namespace http {
Expand Down Expand Up @@ -341,7 +342,13 @@ namespace network {
}
else {
// TODO factory based on HTTP or HTTPS
connection = std::make_shared<client_connection::normal_connection>(pimpl_->io_service_);
if (req.is_https()) {
connection = std::make_shared<client_connection::ssl_connection>(pimpl_->io_service_,
pimpl_->options_);
}
else {
connection = std::make_shared<client_connection::normal_connection>(pimpl_->io_service_);
}
}
return pimpl_->execute(std::make_shared<request_helper>(connection, req, options));
}
Expand Down

0 comments on commit f86503f

Please sign in to comment.