summaryrefslogtreecommitdiff
path: root/src/web_service
diff options
context:
space:
mode:
Diffstat (limited to 'src/web_service')
-rw-r--r--src/web_service/web_backend.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/web_service/web_backend.cpp b/src/web_service/web_backend.cpp
index 74e287045..534960d09 100644
--- a/src/web_service/web_backend.cpp
+++ b/src/web_service/web_backend.cpp
@@ -67,28 +67,25 @@ struct Client::Impl {
67 const std::string& jwt = "", const std::string& username = "", 67 const std::string& jwt = "", const std::string& username = "",
68 const std::string& token = "") { 68 const std::string& token = "") {
69 if (cli == nullptr) { 69 if (cli == nullptr) {
70 auto parsedUrl = LUrlParser::clParseURL::ParseURL(host); 70 const auto parsedUrl = LUrlParser::clParseURL::ParseURL(host);
71 int port; 71 int port{};
72 if (parsedUrl.m_Scheme == "http") { 72 if (parsedUrl.m_Scheme == "http") {
73 if (!parsedUrl.GetPort(&port)) { 73 if (!parsedUrl.GetPort(&port)) {
74 port = HTTP_PORT; 74 port = HTTP_PORT;
75 } 75 }
76 cli = std::make_unique<httplib::Client>(parsedUrl.m_Host.c_str(), port);
77 } else if (parsedUrl.m_Scheme == "https") { 76 } else if (parsedUrl.m_Scheme == "https") {
78 if (!parsedUrl.GetPort(&port)) { 77 if (!parsedUrl.GetPort(&port)) {
79 port = HTTPS_PORT; 78 port = HTTPS_PORT;
80 } 79 }
81 cli = std::make_unique<httplib::SSLClient>(parsedUrl.m_Host.c_str(), port);
82 } else { 80 } else {
83 LOG_ERROR(WebService, "Bad URL scheme {}", parsedUrl.m_Scheme); 81 LOG_ERROR(WebService, "Bad URL scheme {}", parsedUrl.m_Scheme);
84 return WebResult{WebResult::Code::InvalidURL, "Bad URL scheme", ""}; 82 return WebResult{WebResult::Code::InvalidURL, "Bad URL scheme", ""};
85 } 83 }
84 cli = std::make_unique<httplib::Client>(parsedUrl.m_Host.c_str(), port);
86 } 85 }
87 if (cli == nullptr) { 86 cli->set_connection_timeout(TIMEOUT_SECONDS);
88 LOG_ERROR(WebService, "Invalid URL {}", host + path); 87 cli->set_read_timeout(TIMEOUT_SECONDS);
89 return WebResult{WebResult::Code::InvalidURL, "Invalid URL", ""}; 88 cli->set_write_timeout(TIMEOUT_SECONDS);
90 }
91 cli->set_timeout_sec(TIMEOUT_SECONDS);
92 89
93 httplib::Headers params; 90 httplib::Headers params;
94 if (!jwt.empty()) { 91 if (!jwt.empty()) {