HTTP_C::Implement Context::MakeRequest (#4754)

* HTTP_C::Implement Context::MakeRequest

* httplib: Add add_client_cert_ASN1 and set_verify

* HTTP_C: Fix request methode strings case in MakeRequest

* HTTP_C: clang-format and cleanups

* HTTP_C: Add comment about async in BeginRequest and BeginRequestAsync

* Update httplib to contain all the changes we need; adapt http_c and web_services to the changes in httplib; addressed minor review comments

* Add android-ifaddrs
This commit is contained in:
Ben 2020-02-21 19:04:04 +01:00 committed by GitHub
parent 996f1546b2
commit e3dbdcbdff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 5103 additions and 1904 deletions

View file

@ -18,3 +18,6 @@ get_directory_property(OPENSSL_LIBS
DEFINITION OPENSSL_LIBS)
target_compile_definitions(web_service PRIVATE -DCPPHTTPLIB_OPENSSL_SUPPORT)
target_link_libraries(web_service PRIVATE common network json-headers ${OPENSSL_LIBS} httplib lurlparser cpp-jwt)
if (ANDROID)
target_link_libraries(web_service PRIVATE ifaddrs)
endif()

View file

@ -8,6 +8,9 @@
#include <string>
#include <LUrlParser.h>
#include <fmt/format.h>
#if defined(__ANDROID__)
#include <ifaddrs.h>
#endif
#include <httplib.h>
#include "common/common_types.h"
#include "common/logging/log.h"
@ -73,14 +76,14 @@ struct Client::Impl {
if (!parsedUrl.GetPort(&port)) {
port = HTTP_PORT;
}
cli = std::make_unique<httplib::Client>(parsedUrl.m_Host.c_str(), port,
TIMEOUT_SECONDS);
cli = std::make_unique<httplib::Client>(parsedUrl.m_Host.c_str(), port);
cli->set_timeout_sec(TIMEOUT_SECONDS);
} else if (parsedUrl.m_Scheme == "https") {
if (!parsedUrl.GetPort(&port)) {
port = HTTPS_PORT;
}
cli = std::make_unique<httplib::SSLClient>(parsedUrl.m_Host.c_str(), port,
TIMEOUT_SECONDS);
cli = std::make_unique<httplib::SSLClient>(parsedUrl.m_Host.c_str(), port);
cli->set_timeout_sec(TIMEOUT_SECONDS);
} else {
LOG_ERROR(WebService, "Bad URL scheme {}", parsedUrl.m_Scheme);
return Common::WebResult{Common::WebResult::Code::InvalidURL, "Bad URL scheme"};