diff options
| author | Stefan Boberg <[email protected]> | 2021-09-13 22:25:03 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-13 22:25:03 +0200 |
| commit | f277fad0ea747807021bb92ae8fd026384901fb7 (patch) | |
| tree | ffdcb6af33450105d3dc0d5046bec8090d6dff27 /zenhttp/httpsys.cpp | |
| parent | Changed package parsing test code (diff) | |
| download | zen-f277fad0ea747807021bb92ae8fd026384901fb7.tar.xz zen-f277fad0ea747807021bb92ae8fd026384901fb7.zip | |
Implemented intended package streaming API flow (but currently it "streams" from memory)
Diffstat (limited to 'zenhttp/httpsys.cpp')
| -rw-r--r-- | zenhttp/httpsys.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index 737cee509..9ee004c5c 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -1010,9 +1010,18 @@ HttpSysTransaction::InvokeRequestHandler(HttpService& Service, IoBuffer Payload) m_PackageHandler = Service.HandlePackageRequest(ThisRequest); + // TODO: this should really be done in a streaming fashion, currently this emulates + // the intended flow from an API perspective + if (m_PackageHandler) { - CbPackage Package = ParsePackageMessage(ThisRequest.ReadPayload()); + m_PackageHandler->OnRequestBegin(); + + auto CreateBuffer = [&](const IoHash& Cid, uint64_t Size) -> IoBuffer { return m_PackageHandler->CreateTarget(Cid, Size); }; + + CbPackage Package = ParsePackageMessage(ThisRequest.ReadPayload(), CreateBuffer); + + m_PackageHandler->OnRequestComplete(); } } } @@ -1313,7 +1322,8 @@ InitialRequestHandler::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfBytesT { if (m_IsInitialRequest) { - m_ContentLength = GetContentLength(HttpReq); + m_ContentLength = GetContentLength(HttpReq); + const HttpContentType ContentType = GetContentType(HttpReq); if (m_ContentLength) { @@ -1321,8 +1331,6 @@ InitialRequestHandler::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfBytesT // into our embedded request buffer m_PayloadBuffer = IoBuffer(m_ContentLength); - - HttpContentType ContentType = GetContentType(HttpReq); m_PayloadBuffer.SetContentType(ContentType); uint64_t BytesToRead = m_ContentLength; |