Add RestSslClient; add User-Agent header.
This commit is contained in:
@@ -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})
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user