Add RestSslClient; add User-Agent header.

This commit is contained in:
Chunting Gu
2018-10-11 12:47:47 +08:00
parent b02ea902c9
commit d159ce46bf
26 changed files with 232 additions and 169 deletions
+10
View File
@@ -0,0 +1,10 @@
add_executable(rest_github_client main.cc)
set(SSL_LIBS ${OPENSSL_LIBRARIES})
if(WIN32)
set(SSL_LIBS ${SSL_LIBS} crypt32)
endif()
target_link_libraries(rest_github_client webcc ${Boost_LIBRARIES})
target_link_libraries(rest_github_client "${CMAKE_THREAD_LIBS_INIT}")
target_link_libraries(rest_github_client ${SSL_LIBS})
+26
View File
@@ -0,0 +1,26 @@
#include <iostream>
#include "webcc/rest_ssl_client.h"
#include "webcc/logger.h"
void Test() {
webcc::RestSslClient client("api.github.com");
if (client.Get("/events")) {
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;
}