Skip to content

Commit f86503f

Browse files
committed
Added SSL connection to the HTTP client. Untested.
1 parent 8ebb168 commit f86503f

File tree

2 files changed

+14
-55
lines changed

2 files changed

+14
-55
lines changed

http/src/CMakeLists.txt

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# Copyright 2012 A. Joel Lamotte (mjklaim@gmail.com)
44
# Copyright 2011 Google, Inc.
55
# Distributed under the Boost Software License, Version 1.0.
6-
# (See accompanying file LICENSE_1_0.txt or copy at
7-
# http://www.boost.org/LICENSE_1_0.txt)
6+
# (See accompanying file LICENSE_1_0.txt or copy at
7+
# http://www.boost.org/LICENSE_1_0.txt)
88

99

1010
include_directories(
@@ -39,22 +39,6 @@ if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
3939
add_library(cppnetlib-http-message-wrappers ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS})
4040
endif()
4141

42-
#set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS
43-
# http/client_connections.cpp
44-
# http/simple_connection_manager.cpp
45-
# http/simple_connection_factory.cpp
46-
# http/connection_delegate_factory.cpp
47-
# http/client_resolver_delegate.cpp
48-
# http/client_resolver_delegate_factory.cpp
49-
# http/client_connection_delegates.cpp
50-
# http/client_connection_factory.cpp
51-
# http/client_async_resolver.cpp
52-
# http/client_connection_normal.cpp)
53-
#
54-
#if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
55-
# add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS})
56-
#endif()
57-
5842
set(CPP-NETLIB_CONSTANTS_SRCS
5943
constants.cpp)
6044

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

75-
#set(CPP-NETLIB_HTTP_CLIENT_SRCS
76-
# http/client.cpp)
77-
#
78-
#if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
79-
# add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS})
80-
# add_dependencies(cppnetlib-http-client
81-
# ${CPP-NETLIB_LOGGING_LIB}
82-
# cppnetlib-constants
83-
# cppnetlib-uri
84-
# cppnetlib-message
85-
# cppnetlib-message-wrappers
86-
# cppnetlib-message-directives
87-
# cppnetlib-http-message
88-
# cppnetlib-http-message-wrappers
89-
# cppnetlib-http-client-connections
90-
# )
91-
# target_link_libraries(cppnetlib-http-client
92-
# ${Boost_LIBRARIES}
93-
# ${CPP-NETLIB_LOGGING_LIB}
94-
# cppnetlib-constants
95-
# cppnetlib-uri
96-
# cppnetlib-message
97-
# cppnetlib-message-wrappers
98-
# cppnetlib-message-directives
99-
# cppnetlib-http-message
100-
# cppnetlib-http-message-wrappers
101-
# cppnetlib-http-client-connections
102-
# )
103-
#endif()
104-
105-
59+
# HTTP client
10660
set(CPP-NETLIB_HTTP_V2_CLIENT_SRCS
10761
${CMAKE_CURRENT_SOURCE_DIR}/http/v2/client/client.cpp
10862
${CMAKE_CURRENT_SOURCE_DIR}/http/v2/client/client_errors.cpp
@@ -115,23 +69,21 @@ target_link_libraries(network-http-v2-client
11569
${Boost_LIBRARIES}
11670
network-uri
11771
)
72+
if (OPENSSL_FOUND)
73+
target_link_libraries(network-http-v2-client ${OPENSSL_LIBRARIES})
74+
endif()
11875

11976
# prepend current directory to make paths absolute
12077
prependToElements( "${CMAKE_CURRENT_SOURCE_DIR}/"
12178
CPP-NETLIB_HTTP_MESSAGE_SRCS
12279
CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS
123-
# CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS
12480
CPP-NETLIB_CONSTANTS_SRCS
12581
CPP-NETLIB_HTTP_SERVER_SRCS
126-
# CPP-NETLIB_HTTP_CLIENT_SRCS
12782
CPP-NETLIB_HTTP_V2_CLIENT_SRCS )
12883

129-
13084
# propagate sources to parent directory for one-lib-build
13185
set(CPP-NETLIB_HTTP_MESSAGE_SRCS ${CPP-NETLIB_HTTP_MESSAGE_SRCS} PARENT_SCOPE)
13286
set(CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS} PARENT_SCOPE)
133-
#set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS} PARENT_SCOPE)
134-
#set(CPP-NETLIB_HTTP_CLIENT_SRCS ${CPP-NETLIB_HTTP_CLIENT_SRCS} PARENT_SCOPE)
13587
set(CPP-NETLIB_HTTP_SERVER_SRCS ${CPP-NETLIB_HTTP_SERVER_SRCS} PARENT_SCOPE)
13688
set(CPP-NETLIB_CONSTANTS_SRCS ${CPP-NETLIB_CONSTANTS_SRCS} PARENT_SCOPE)
13789
set(CPP-NETLIB_HTTP_V2_CLIENT_SRCS ${CPP-NETLIB_HTTP_V2_CLIENT_SRCS} PARENT SCOPE)

http/src/http/v2/client/client.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <network/http/v2/client/response.hpp>
1717
#include <network/http/v2/client/connection/tcp_resolver.hpp>
1818
#include <network/http/v2/client/connection/normal_connection.hpp>
19+
#include <network/http/v2/client/connection/ssl_connection.hpp>
1920

2021
namespace network {
2122
namespace http {
@@ -341,7 +342,13 @@ namespace network {
341342
}
342343
else {
343344
// TODO factory based on HTTP or HTTPS
344-
connection = std::make_shared<client_connection::normal_connection>(pimpl_->io_service_);
345+
if (req.is_https()) {
346+
connection = std::make_shared<client_connection::ssl_connection>(pimpl_->io_service_,
347+
pimpl_->options_);
348+
}
349+
else {
350+
connection = std::make_shared<client_connection::normal_connection>(pimpl_->io_service_);
351+
}
345352
}
346353
return pimpl_->execute(std::make_shared<request_helper>(connection, req, options));
347354
}

0 commit comments

Comments
 (0)