Add HTTP SSL client exmaple.
parent
3693d881c7
commit
5fd5d8ff15
@ -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})
|
@ -0,0 +1,31 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
Loading…
Reference in New Issue