add user support to database

This commit is contained in:
Syping 2026-03-25 23:42:34 +01:00
parent 3546eed2dd
commit bb5adf587c
10 changed files with 205 additions and 12 deletions

View file

@ -17,7 +17,6 @@
*****************************************************************************/
#include "http_request.h"
using namespace std::string_literals;
http_request::http_request() {
instance = curl_easy_init();
@ -56,7 +55,7 @@ const http_response http_request::post(const std::string &url, const std::string
curl_easy_setopt(instance, CURLOPT_URL, url.c_str());
curl_slist *header_slist = nullptr;
if (!content_type.empty()) {
curl_slist *new_header_slist = curl_slist_append(header_slist, std::string("Content-Type: "s + content_type).c_str());
curl_slist *new_header_slist = curl_slist_append(header_slist, std::string("Content-Type: " + content_type).c_str());
if (!new_header_slist) {
curl_slist_free_all(header_slist);
throw std::bad_alloc();
@ -88,7 +87,7 @@ const http_response http_request::post(const std::string &url, const std::string
}
std::string http_request::legacy_url(const std::string &hostname, uint16_t port, const std::string &url, bool tls) {
return (tls ? "https://"s : "http://"s) + hostname + ":"s + std::to_string(port) + (url.empty() ? "/"s : (url.front() != '/' ? "/"s + url : url));
return (tls ? "https://" : "http://") + hostname + ":" + std::to_string(port) + (url.empty() ? "/" : (url.front() != '/' ? "/" + url : url));
}
http_request::~http_request() {