C++ IIS module: IHttpRequest::ReadEntityBody returns 0x80070001 (ERROR_INVALID_FUNCTION)
Got native C++ IIS module. IHttpRequest::ReadEntityBody() is used to read body of a very long PUT request that uses chunked encoding, basically a stream of unknown size. ReadEntityBody() can succeed a hundred times or hundreds of thousands times but then the call fails with error 0x80070001, which is ERROR_INVALID_FUNCTION converted to HRESULT.
The size of the buffer where data is read into does not matter. Asynchronous or synchronous reading fails the same way.
Failed Request Tracing did not reveal anything useful, but pointed me to the very old thread - Error during GENERAL_REQUEST_ENTITY for POST request causes ASP .NET session state to never get unlocked
The problem looks similar except that there is no ASP.NET in my case, there is no ASP, nothing, except for a minimal IIS and my custom IIS module.
The solution with "read ahead" setting does not help in my case although the setting is still there, the mentioned hot fix is obviously not available after 11 years and OS I have is Windows Server 2022. The problem is also reproducible on previous server versions.
There is also no Session module involved in my scenario. It looks like some sort of bug is still in either IIS or HTTP driver.
The interesting thing is that the same code works just fine if connection uses HTTPS, the problem occurs over HTTP only. That points to the direction of the same "read ahead" buffer bug, because the stream data is being combined differently when data is being received over SSL connection, but again the setting that helped somebody does not help me much.
Any ideas? because I'm stuck
Could you tell me when ReadEntityBody can return 0x80070001 ?
Thanks in advance!