From 4e2649977d034b913413d2cb35d4a88afc30393f Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 13 Sep 2021 12:24:59 +0200 Subject: Changed interface for httpServerRequest::SessionId()/RequestId() so they share storage and lazy eval logic They now call into ParseSessionId()/ParseRequestId() when required Eliminates redundant logic in derived implementations Also moved package transport code into httpshared.(cpp|h) for easier sharing with client code Added some I/O error reporting in http.sys related code Changed IHttpPackageHandler interface to support partially updated handling flow --- zenhttp/httpshared.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 zenhttp/httpshared.h (limited to 'zenhttp/httpshared.h') diff --git a/zenhttp/httpshared.h b/zenhttp/httpshared.h new file mode 100644 index 000000000..dbbebb348 --- /dev/null +++ b/zenhttp/httpshared.h @@ -0,0 +1,32 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include + +namespace zen { + +class IoBuffer; +class CbPackage; + +struct CbPackageHeader +{ + uint32_t HeaderMagic; + uint32_t AttachmentCount; + uint32_t Reserved1; + uint32_t Reserved2; +}; + +static constinit uint32_t kCbPkgMagic = 0xaa77aacc; + +struct CbAttachmentEntry +{ + uint64_t AttachmentSize; + uint32_t Reserved1; + IoHash AttachmentHash; +}; + +std::vector FormatPackageMessage(const CbPackage& Data); +CbPackage ParsePackageMessage(IoBuffer Payload); + +} // namespace zen -- cgit v1.2.3 From 0018d8b4e4e9e8524bf8ed2ac5b61ef987b852a9 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 13 Sep 2021 16:57:19 +0200 Subject: Enforce sizes of package serialization structures --- zenhttp/httpshared.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'zenhttp/httpshared.h') diff --git a/zenhttp/httpshared.h b/zenhttp/httpshared.h index dbbebb348..fbf35076b 100644 --- a/zenhttp/httpshared.h +++ b/zenhttp/httpshared.h @@ -17,6 +17,8 @@ struct CbPackageHeader uint32_t Reserved2; }; +static_assert(sizeof(CbPackageHeader) == 16); + static constinit uint32_t kCbPkgMagic = 0xaa77aacc; struct CbAttachmentEntry @@ -26,6 +28,8 @@ struct CbAttachmentEntry IoHash AttachmentHash; }; +static_assert(sizeof(CbAttachmentEntry) == 32); + std::vector FormatPackageMessage(const CbPackage& Data); CbPackage ParsePackageMessage(IoBuffer Payload); -- cgit v1.2.3 From 11a2c78d69878e40a6ebafd00fd543f1f2eab702 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 13 Sep 2021 21:43:18 +0200 Subject: Introduced FormatPackageMessageBuffer() returning a ComositeBuffer --- zenhttp/httpshared.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'zenhttp/httpshared.h') diff --git a/zenhttp/httpshared.h b/zenhttp/httpshared.h index fbf35076b..e7c9e4a56 100644 --- a/zenhttp/httpshared.h +++ b/zenhttp/httpshared.h @@ -8,6 +8,7 @@ namespace zen { class IoBuffer; class CbPackage; +class CompositeBuffer; struct CbPackageHeader { @@ -31,6 +32,7 @@ struct CbAttachmentEntry static_assert(sizeof(CbAttachmentEntry) == 32); std::vector FormatPackageMessage(const CbPackage& Data); +CompositeBuffer FormatPackageMessageBuffer(const CbPackage& Data); CbPackage ParsePackageMessage(IoBuffer Payload); } // namespace zen -- cgit v1.2.3 From f277fad0ea747807021bb92ae8fd026384901fb7 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 13 Sep 2021 22:25:03 +0200 Subject: Implemented intended package streaming API flow (but currently it "streams" from memory) --- zenhttp/httpshared.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'zenhttp/httpshared.h') diff --git a/zenhttp/httpshared.h b/zenhttp/httpshared.h index e7c9e4a56..06fdb104f 100644 --- a/zenhttp/httpshared.h +++ b/zenhttp/httpshared.h @@ -2,8 +2,11 @@ #pragma once +#include #include +#include + namespace zen { class IoBuffer; @@ -33,6 +36,10 @@ static_assert(sizeof(CbAttachmentEntry) == 32); std::vector FormatPackageMessage(const CbPackage& Data); CompositeBuffer FormatPackageMessageBuffer(const CbPackage& Data); -CbPackage ParsePackageMessage(IoBuffer Payload); +CbPackage ParsePackageMessage( + IoBuffer Payload, + std::function CreateBuffer = [](const IoHash&, uint64_t Size) -> IoBuffer { + return IoBuffer{Size}; + }); } // namespace zen -- cgit v1.2.3