add request and response sizes v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Thu, 21 Apr 2022 00:23:08 +0200
branchv_0
changeset 6 b04bde9083d4
parent 5 121981e6bd54
child 7 315d985f8424
add request and response sizes
src/HTTPDHandler.h
--- a/src/HTTPDHandler.h	Sat Apr 16 02:43:50 2022 +0200
+++ b/src/HTTPDHandler.h	Thu Apr 21 00:23:08 2022 +0200
@@ -53,7 +53,6 @@
 	std::shared_ptr<HTTPServer> httpServer;
 	relpipe::common::type::StringX currentRelationName;
 	std::vector<relpipe::reader::handlers::AttributeMetadata> currentReaderMetadata;
-	std::vector<relpipe::writer::AttributeMetadata> currentWriterMetadata;
 	size_t currentAttributeIndex = 0;
 	size_t currentRecordNumber = 1;
 
@@ -113,7 +112,7 @@
 		void writeExchange(const HTTPServer::Request& request, const HTTPServer::Response& response) {
 			std::wstring_convert < codecvt_utf8<wchar_t>> convertor; // TODO: support also other encoding than UTF-8
 			std::lock_guard<std::mutex> lock(*relationalWriterMutex);
-			
+
 			auto exchangeId = convertor.from_bytes(generateExchangeId());
 
 
@@ -125,27 +124,37 @@
 			// TODO: support multiple encodings
 
 			relationalWriter->startRelation(L"exchange",{
+				// TODO: timestamp
+				// TODO: ordinal number?
 				{L"id", relpipe::writer::TypeId::STRING},
 				{L"url", relpipe::writer::TypeId::STRING},
 				{L"method", relpipe::writer::TypeId::STRING},
 				{L"request_text", relpipe::writer::TypeId::STRING},
 				{L"request_data", relpipe::writer::TypeId::STRING},
+				{L"request_size", relpipe::writer::TypeId::INTEGER},
 				{L"response_text", relpipe::writer::TypeId::STRING},
 				{L"response_data", relpipe::writer::TypeId::STRING},
+				{L"response_size", relpipe::writer::TypeId::INTEGER},
 				{L"response_code", relpipe::writer::TypeId::INTEGER},
 			}, true);
 
+			relpipe::common::type::Integer requestSize = request.body.size();
+			relpipe::common::type::Integer responseSize = response.body.size();
+
 			relationalWriter->writeAttribute(exchangeId);
 			relationalWriter->writeAttribute(convertor.from_bytes(request.url));
 			relationalWriter->writeAttribute(convertor.from_bytes(request.method));
 			relationalWriter->writeAttribute(bodyToText(convertor, request.body));
 			relationalWriter->writeAttribute(bodyToHex(convertor, request.body));
+			relationalWriter->writeAttribute(&requestSize, typeid (requestSize));
 			relationalWriter->writeAttribute(bodyToText(convertor, response.body));
 			relationalWriter->writeAttribute(bodyToHex(convertor, response.body));
+			relationalWriter->writeAttribute(&responseSize, typeid (responseSize));
 			relationalWriter->writeAttribute(std::to_wstring(response.code));
 
 
 			relationalWriter->startRelation(L"header",{
+				// TODO: ordinal number?
 				{L"exchange", relpipe::writer::TypeId::STRING},
 				{L"url", relpipe::writer::TypeId::STRING},
 				{L"direction", relpipe::writer::TypeId::STRING},