diff --git a/example/http_ssl_client/CMakeLists.txt b/example/http_ssl_client/CMakeLists.txt new file mode 100644 index 0000000..b9b4247 --- /dev/null +++ b/example/http_ssl_client/CMakeLists.txt @@ -0,0 +1,10 @@ +add_executable(http_ssl_client main.cc) + +set(SSL_LIBS ${OPENSSL_LIBRARIES}) +if(WIN32) + set(SSL_LIBS ${SSL_LIBS} crypt32) +endif() + +target_link_libraries(http_ssl_client webcc ${Boost_LIBRARIES}) +target_link_libraries(http_ssl_client "${CMAKE_THREAD_LIBS_INIT}") +target_link_libraries(http_ssl_client ${SSL_LIBS}) diff --git a/example/http_ssl_client/main.cc b/example/http_ssl_client/main.cc new file mode 100644 index 0000000..d33f7f5 --- /dev/null +++ b/example/http_ssl_client/main.cc @@ -0,0 +1,31 @@ +#include + +#include "webcc/http_ssl_client.h" +#include "webcc/logger.h" + +void Test() { + webcc::HttpRequest request; + request.set_method(webcc::kHttpGet); + request.set_url("/LICENSE_1_0.txt"); + request.SetHost("www.boost.org", "443"); + request.UpdateStartLine(); + + webcc::HttpSslClient client; + if (client.Request(request)) { + std::cout << client.response()->content() << std::endl; + } else { + std::cout << webcc::DescribeError(client.error()); + if (client.timed_out()) { + std::cout << " (timed out)"; + } + std::cout << std::endl; + } +} + +int main() { + WEBCC_LOG_INIT("", webcc::LOG_CONSOLE); + + Test(); + + return 0; +}