--- a/src/HTTPHandler.h Tue Mar 22 22:00:59 2022 +0100
+++ b/src/HTTPHandler.h Tue Mar 22 22:08:03 2022 +0100
@@ -64,6 +64,7 @@
std::vector<relpipe::reader::handlers::AttributeMetadata> currentReaderMetadata;
std::vector<relpipe::writer::AttributeMetadata> currentWriterMetadata;
HeaderDefinition requestHeader;
+ relpipe::common::type::StringX requestId;
HTTPClient::Request request;
std::vector<HeaderDefinition> requestHeaders;
std::vector<relpipe::common::type::StringX> responseHeaders;
@@ -73,7 +74,7 @@
void writeHeaders() {
if (responseHeaders.size()) {
relationalWriter->startRelation(L"header",{
- // TODO: request ID instead of URL (or both)
+ {L"request", relpipe::writer::TypeId::STRING},
{L"url", relpipe::writer::TypeId::STRING},
{L"name", relpipe::writer::TypeId::STRING},
{L"value", relpipe::writer::TypeId::STRING},
@@ -133,8 +134,8 @@
// TODO: analyze header attributes
} else if (currentRelationName == L"request") {
relationalWriter->startRelation(L"response",{
- // TODO: request ID
// TODO: body in hexadecimal/binary format
+ {L"request", relpipe::writer::TypeId::STRING},
{L"url", relpipe::writer::TypeId::STRING},
{L"body", relpipe::writer::TypeId::STRING},
{L"code", relpipe::writer::TypeId::INTEGER},
@@ -171,7 +172,8 @@
void requestAttribute(const relpipe::common::type::StringX& value) {
auto attributeName = currentReaderMetadata[currentAttributeIndex].getAttributeName();
- if (attributeName == L"url") request.url = convertor.to_bytes(value);
+ if (attributeName == L"id") requestId = value;
+ else if (attributeName == L"url") request.url = convertor.to_bytes(value);
else if (attributeName == L"method") request.method = parseMethod(value);
else if (isHeaderAttribute(attributeName)) appendRequestHeader(fetchHeaderName(attributeName), value);
else throw std::invalid_argument("Unsupported attribute in the header relation: " + convertor.to_bytes(attributeName + L" = " + value));
@@ -193,6 +195,7 @@
body = response.body;
for (size_t i = 0; i < response.headers.size(); i += 2) {
+ responseHeaders.push_back(requestId);
responseHeaders.push_back(convertor.from_bytes(request.url));
responseHeaders.push_back(convertor.from_bytes(response.headers[i]));
responseHeaders.push_back(convertor.from_bytes(response.headers[i + 1]));
@@ -202,11 +205,13 @@
// TODO: move error message into separate attribute?
}
+ relationalWriter->writeAttribute(requestId);
relationalWriter->writeAttribute(convertor.from_bytes(request.url));
relationalWriter->writeAttribute(convertor.from_bytes(body));
relationalWriter->writeAttribute(&responseCode, typeid (responseCode));
request = HTTPClient::Request();
+ requestId.clear();
}
}