--- a/src/HTTPHandler.h Tue Mar 22 22:08:03 2022 +0100
+++ b/src/HTTPHandler.h Thu Mar 24 02:02:48 2022 +0100
@@ -48,12 +48,16 @@
class HeaderDefinition {
public:
+ std::wregex request = std::wregex(L".*");
std::wregex url = std::wregex(L".*");
relpipe::common::type::StringX name;
relpipe::common::type::StringX value;
- bool matches(const relpipe::common::type::StringX& url) const {
- return std::regex_match(url, this->url);
+ bool matches(const relpipe::common::type::StringX& request, const relpipe::common::type::StringX& url) const {
+ bool result = false;
+ result |= std::regex_match(request, this->request);
+ result |= std::regex_match(url, this->url);
+ return result;
}
};
@@ -156,6 +160,7 @@
if (attributeName == L"name") requestHeader.name = value;
else if (attributeName == L"value") requestHeader.value = value;
+ else if (attributeName == L"request") requestHeader.request = std::wregex(value.size() ? value : L".*"); // TODO: null instead of empty value (when supported)
else if (attributeName == L"url") requestHeader.url = std::wregex(value.size() ? value : L".*"); // TODO: null instead of empty value (when supported)
else throw std::invalid_argument("Unsupported attribute in the header relation: " + convertor.to_bytes(attributeName + L" = " + value));
@@ -184,7 +189,7 @@
currentAttributeIndex = 0;
std::shared_ptr<HTTPClient> http(HTTPClient::open());
- for (const HeaderDefinition& h : requestHeaders) if (h.matches(convertor.from_bytes(request.url))) appendRequestHeader(h.name, h.value);
+ for (const HeaderDefinition& h : requestHeaders) if (h.matches(requestId, convertor.from_bytes(request.url))) appendRequestHeader(h.name, h.value);
std::string body;
relpipe::common::type::Integer responseCode = -1;