--- a/nbproject/configurations.xml Thu Mar 24 02:02:48 2022 +0100
+++ b/nbproject/configurations.xml Thu Mar 24 02:19:39 2022 +0100
@@ -86,6 +86,7 @@
<pElem>../relpipe-lib-common.cpp/include</pElem>
<pElem>../relpipe-lib-cli.cpp/include</pElem>
<pElem>/usr/include/x86_64-linux-gnu</pElem>
+ <pElem>/usr/include/uuid</pElem>
<pElem>build/Debug/src</pElem>
</incDir>
</ccTool>
@@ -97,8 +98,8 @@
</preBuild>
</makefileType>
<item path="src/HTTPClient.cpp" ex="false" tool="1" flavor2="0">
- </item>
- <item path="src/HTTPClient.h" ex="false" tool="3" flavor2="0">
+ <ccTool flags="0">
+ </ccTool>
</item>
<item path="src/relpipe-tr-http.cpp" ex="false" tool="1" flavor2="0">
<ccTool flags="0">
--- a/src/CMakeLists.txt Thu Mar 24 02:02:48 2022 +0100
+++ b/src/CMakeLists.txt Thu Mar 24 02:19:39 2022 +0100
@@ -17,7 +17,7 @@
# Relpipe libraries:
INCLUDE(FindPkgConfig)
-pkg_check_modules (RELPIPE_LIBS relpipe-lib-reader.cpp relpipe-lib-writer.cpp relpipe-lib-cli.cpp libcurl)
+pkg_check_modules (RELPIPE_LIBS relpipe-lib-reader.cpp relpipe-lib-writer.cpp relpipe-lib-cli.cpp libcurl uuid)
include_directories(${RELPIPE_LIBS_INCLUDE_DIRS})
link_directories(${RELPIPE_LIBS_LIBRARY_DIRS})
--- a/src/HTTPHandler.h Thu Mar 24 02:02:48 2022 +0100
+++ b/src/HTTPHandler.h Thu Mar 24 02:19:39 2022 +0100
@@ -25,6 +25,7 @@
#include <stdexcept>
#include <curl/curl.h>
+#include <uuid/uuid.h>
#include <relpipe/common/type/typedefs.h>
#include <relpipe/reader/TypeId.h>
@@ -119,6 +120,15 @@
request.headers.push_back(convertor.to_bytes(value));
}
+ relpipe::common::type::StringX generateRequestId() {
+ char buffer[37];
+ uuid_t uuid;
+ uuid_generate_random(uuid);
+ // uuid_generate_time(uuid);
+ uuid_unparse_lower(uuid, buffer);
+ return convertor.from_bytes(buffer);
+ }
+
public:
HTTPHandler(shared_ptr<relpipe::writer::RelationalWriter> relationalWriter, Configuration configuration) : relationalWriter(relationalWriter), configuration(configuration) {
@@ -189,6 +199,8 @@
currentAttributeIndex = 0;
std::shared_ptr<HTTPClient> http(HTTPClient::open());
+ if (requestId.empty()) requestId = generateRequestId();
+
for (const HeaderDefinition& h : requestHeaders) if (h.matches(requestId, convertor.from_bytes(request.url))) appendRequestHeader(h.name, h.value);
std::string body;