From dae750d7dfa576b516ff55d6d486114b665103dc Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 5 Sep 2025 00:14:24 +0100 Subject: Change getUserAgentDetail to return a packaged CURL object This will be usable with curl_multi_* instead of being a single synchronous request. --- src/uaLookup.hpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/uaLookup.hpp') diff --git a/src/uaLookup.hpp b/src/uaLookup.hpp index 5492f05..843283e 100644 --- a/src/uaLookup.hpp +++ b/src/uaLookup.hpp @@ -1,6 +1,8 @@ #pragma once +#include "util.hpp" #include +#include #include #include @@ -12,5 +14,21 @@ namespace WebStat { CURLcode code; }; - std::string getUserAgentDetail(std::string_view uas, const char * baseUrl = "https://useragentstring.com"); + using CurlPtr = std::unique_ptr>; + using CurlMimePtr = std::unique_ptr>; + using CurlErrorBuf = std::array; + + class CurlOperation { + public: + CurlOperation(); + void addForm(const char * name, std::string_view data); + + CurlPtr hnd; + CurlMimePtr mime; + CurlErrorBuf err; + std::string result; + }; + + std::unique_ptr curlGetUserAgentDetail( + std::string_view uas, const char * baseUrl = "https://useragentstring.com"); } -- cgit v1.2.3