From 7a14be006dc63ccf66d9a800b89fed023a074da5 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 9 Apr 2018 15:16:47 -0700 Subject: [PATCH] Fast reads --- src/RequestHandler/managedexports.cxx | 28 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/RequestHandler/managedexports.cxx b/src/RequestHandler/managedexports.cxx index 46510a00b7..5608aac3e5 100644 --- a/src/RequestHandler/managedexports.cxx +++ b/src/RequestHandler/managedexports.cxx @@ -206,18 +206,26 @@ http_read_request_bytes( } IHttpRequest *pHttpRequest = (IHttpRequest*)pInProcessHandler->QueryHttpContext()->GetRequest(); - BOOL fAsync = TRUE; - hr = pHttpRequest->ReadEntityBody( - pvBuffer, - dwCbBuffer, - fAsync, - pdwBytesReceived, - pfCompletionPending); - - if (hr == HRESULT_FROM_WIN32(ERROR_HANDLE_EOF)) + if (pHttpRequest->GetRemainingEntityBytes() > 0) { - // We reached the end of the data + BOOL fAsync = TRUE; + hr = pHttpRequest->ReadEntityBody( + pvBuffer, + dwCbBuffer, + fAsync, + pdwBytesReceived, + pfCompletionPending); + + if (hr == HRESULT_FROM_WIN32(ERROR_HANDLE_EOF)) + { + // We reached the end of the data + hr = S_OK; + } + } + else + { + // nothing to read hr = S_OK; }