summaryrefslogtreecommitdiff
path: root/src/uaLookup.hpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-09-13 13:24:23 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2025-09-13 13:24:23 +0100
commit84bd17328a4dc027e689ca7b2a85744d6e2b7cf5 (patch)
treee1d2e7c0f5b26500715c8cb17a12a391afc032b8 /src/uaLookup.hpp
parent55439681e7a45489e5a77c2d6169f4b722525c96 (diff)
downloadwebstat-84bd17328a4dc027e689ca7b2a85744d6e2b7cf5.tar.bz2
webstat-84bd17328a4dc027e689ca7b2a85744d6e2b7cf5.tar.xz
webstat-84bd17328a4dc027e689ca7b2a85744d6e2b7cf5.zip
Create and perform UA lookup curl op when new user agent is encountered
Diffstat (limited to 'src/uaLookup.hpp')
-rw-r--r--src/uaLookup.hpp31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/uaLookup.hpp b/src/uaLookup.hpp
index 5529a40..9714253 100644
--- a/src/uaLookup.hpp
+++ b/src/uaLookup.hpp
@@ -1,34 +1,21 @@
#pragma once
-#include "util.hpp"
+#include "curlOp.hpp"
+#include "logTypes.hpp"
+#include <connection_fwd.h>
#include <curl/curl.h>
#include <memory>
-#include <stdexcept>
-#include <string>
namespace WebStat {
- class CurlError : public std::runtime_error {
+ class UserAgentLookupOperation : public CurlOperation {
public:
- explicit CurlError(CURLcode code, const char * msg) : std::runtime_error {msg}, code(code) { }
+ UserAgentLookupOperation(Crc32Value entityId);
- CURLcode code;
- };
-
- using CurlPtr = std::unique_ptr<CURL, DeleteWith<&curl_easy_cleanup>>;
- using CurlMimePtr = std::unique_ptr<curl_mime, DeleteWith<&curl_mime_free>>;
- using CurlErrorBuf = std::array<char, CURL_ERROR_SIZE>;
- using CurlMultiPtr = std::unique_ptr<CURLM, DeleteWith<&curl_multi_cleanup>>;
-
- class CurlOperation {
- public:
- CurlOperation();
- void addForm(const char * name, std::string_view data);
+ void whenComplete(DB::Connection *) const override;
- CurlPtr hnd;
- CurlMimePtr mime;
- CurlErrorBuf err;
- std::string result;
+ Crc32Value entityId;
};
- std::unique_ptr<CurlOperation> curlGetUserAgentDetail(std::string_view uas, const char * baseUrl);
+ std::unique_ptr<CurlOperation> curlGetUserAgentDetail(
+ Crc32Value entityId, std::string_view uas, const char * baseUrl);
}