From 6a74449307c699172dc4c93e1a0e8ecfbaced675 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 12 May 2021 09:25:39 +0200 Subject: Added chunking to HttpSysServerRequest::ReadPayload to deal with large payloads better --- zencore/httpserver.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'zencore/httpserver.cpp') diff --git a/zencore/httpserver.cpp b/zencore/httpserver.cpp index 52389a11b..22cba4d75 100644 --- a/zencore/httpserver.cpp +++ b/zencore/httpserver.cpp @@ -1044,15 +1044,19 @@ public: // Call http.sys API to receive the remaining data + static const uint64_t kMaxBytesPerApiCall = 1 * 1024 * 1024; + while (BytesToRead) { ULONG BytesRead = 0; + const uint64_t BytesToReadThisCall = zen::Min(BytesToRead, kMaxBytesPerApiCall); + ULONG ApiResult = HttpReceiveRequestEntityBody(m_HttpTx.RequestQueueHandle(), HttpReq->RequestId, 0, /* Flags */ ReadPointer, - (ULONG)BytesToRead, + gsl::narrow(BytesToReadThisCall), &BytesRead, NULL /* Overlapped */ ); -- cgit v1.2.3