summaryrefslogtreecommitdiff
path: root/src/web_service/web_backend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/web_service/web_backend.cpp')
-rw-r--r--src/web_service/web_backend.cpp20
1 files changed, 1 insertions, 19 deletions
diff --git a/src/web_service/web_backend.cpp b/src/web_service/web_backend.cpp
index 534960d09..c56cd7c71 100644
--- a/src/web_service/web_backend.cpp
+++ b/src/web_service/web_backend.cpp
@@ -7,7 +7,6 @@
7#include <mutex> 7#include <mutex>
8#include <string> 8#include <string>
9 9
10#include <LUrlParser.h>
11#include <fmt/format.h> 10#include <fmt/format.h>
12#include <httplib.h> 11#include <httplib.h>
13 12
@@ -19,9 +18,6 @@ namespace WebService {
19 18
20constexpr std::array<const char, 1> API_VERSION{'1'}; 19constexpr std::array<const char, 1> API_VERSION{'1'};
21 20
22constexpr int HTTP_PORT = 80;
23constexpr int HTTPS_PORT = 443;
24
25constexpr std::size_t TIMEOUT_SECONDS = 30; 21constexpr std::size_t TIMEOUT_SECONDS = 30;
26 22
27struct Client::Impl { 23struct Client::Impl {
@@ -67,21 +63,7 @@ struct Client::Impl {
67 const std::string& jwt = "", const std::string& username = "", 63 const std::string& jwt = "", const std::string& username = "",
68 const std::string& token = "") { 64 const std::string& token = "") {
69 if (cli == nullptr) { 65 if (cli == nullptr) {
70 const auto parsedUrl = LUrlParser::clParseURL::ParseURL(host); 66 cli = std::make_unique<httplib::Client>(host.c_str());
71 int port{};
72 if (parsedUrl.m_Scheme == "http") {
73 if (!parsedUrl.GetPort(&port)) {
74 port = HTTP_PORT;
75 }
76 } else if (parsedUrl.m_Scheme == "https") {
77 if (!parsedUrl.GetPort(&port)) {
78 port = HTTPS_PORT;
79 }
80 } else {
81 LOG_ERROR(WebService, "Bad URL scheme {}", parsedUrl.m_Scheme);
82 return WebResult{WebResult::Code::InvalidURL, "Bad URL scheme", ""};
83 }
84 cli = std::make_unique<httplib::Client>(parsedUrl.m_Host.c_str(), port);
85 } 67 }
86 cli->set_connection_timeout(TIMEOUT_SECONDS); 68 cli->set_connection_timeout(TIMEOUT_SECONDS);
87 cli->set_read_timeout(TIMEOUT_SECONDS); 69 cli->set_read_timeout(TIMEOUT_SECONDS);