Port Handle EOF HResult from async callback to 2.2 (#6483)
This commit is contained in:
parent
5fd9435392
commit
437baf6f5e
|
|
@ -27,9 +27,10 @@ Later on, this will be checked using this condition:
|
|||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(VersionPrefix)' == '2.2.2' ">
|
||||
<PackagesInPatch>
|
||||
@aspnet/signalr;
|
||||
Microsoft.AspNetCore.AspNetCoreModuleV2;
|
||||
Microsoft.AspNetCore.Authentication.Google;
|
||||
Microsoft.AspNetCore.Http;
|
||||
Microsoft.AspNetCore.Server.IIS;
|
||||
</PackagesInPatch>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -243,12 +243,6 @@ http_read_request_bytes(
|
|||
fAsync,
|
||||
pdwBytesReceived,
|
||||
pfCompletionPending);
|
||||
|
||||
if (hr == HRESULT_FROM_WIN32(ERROR_HANDLE_EOF))
|
||||
{
|
||||
// We reached the end of the data
|
||||
hr = S_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -330,12 +324,6 @@ http_websockets_read_bytes(
|
|||
pDwBytesReceived,
|
||||
pfCompletionPending);
|
||||
|
||||
if (hr == HRESULT_FROM_WIN32(ERROR_HANDLE_EOF))
|
||||
{
|
||||
// We reached the end of the data
|
||||
hr = S_OK;
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ namespace Microsoft.AspNetCore.Server.IIS.Core.IO
|
|||
{
|
||||
_inputHandle.Dispose();
|
||||
}
|
||||
|
||||
protected override bool IsSuccessfulResult(int hr) => hr == NativeMethods.ERROR_HANDLE_EOF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Server.IIS.Core.IO
|
|||
if (hr != NativeMethods.ERROR_OPERATION_ABORTED)
|
||||
{
|
||||
_result = bytes;
|
||||
if (hr != NativeMethods.HR_OK)
|
||||
if (hr != NativeMethods.HR_OK && !IsSuccessfulResult(hr))
|
||||
{
|
||||
// Treat all errors as the client disconnect
|
||||
_exception = new ConnectionResetException("The client has disconnected", Marshal.GetExceptionForHR(hr));
|
||||
|
|
@ -126,6 +126,8 @@ namespace Microsoft.AspNetCore.Server.IIS.Core.IO
|
|||
return asyncContinuation;
|
||||
}
|
||||
|
||||
protected virtual bool IsSuccessfulResult(int hr) => false;
|
||||
|
||||
public virtual void FreeOperationResources(int hr, int bytes) { }
|
||||
|
||||
protected virtual void ResetOperation()
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ namespace Microsoft.AspNetCore.Server.IIS.Core.IO
|
|||
|
||||
_engine.ReturnOperation(this);
|
||||
}
|
||||
|
||||
protected override bool IsSuccessfulResult(int hr) => hr == NativeMethods.ERROR_HANDLE_EOF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Server.IIS
|
|||
internal const int ERROR_NOT_FOUND = unchecked((int)0x80070490);
|
||||
internal const int ERROR_OPERATION_ABORTED = unchecked((int)0x800703E3);
|
||||
internal const int ERROR_INVALID_PARAMETER = unchecked((int)0x80070057);
|
||||
internal const int COR_E_IO = unchecked((int)0x80131620);
|
||||
internal const int ERROR_HANDLE_EOF = unchecked((int)0x80070026);
|
||||
|
||||
private const string KERNEL32 = "kernel32.dll";
|
||||
|
||||
|
|
|
|||
|
|
@ -193,5 +193,44 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
await connection.WaitForConnectionClose();
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[RequiresNewHandler]
|
||||
public async Task AsyncChunkedPostIsAccepted()
|
||||
{
|
||||
// This test sends a lot of request because we are trying to force
|
||||
// different async completion modes from IIS
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
using (var connection = _fixture.CreateTestConnection())
|
||||
{
|
||||
await connection.Send(
|
||||
"POST /ReadFullBody HTTP/1.1",
|
||||
$"Transfer-Encoding: chunked",
|
||||
"Host: localhost",
|
||||
"Connection: close",
|
||||
"",
|
||||
"");
|
||||
|
||||
await connection.Send("5",
|
||||
"Hello",
|
||||
"");
|
||||
|
||||
await connection.Send(
|
||||
"0",
|
||||
"",
|
||||
"");
|
||||
|
||||
await connection.Receive(
|
||||
"HTTP/1.1 200 OK",
|
||||
"");
|
||||
|
||||
await connection.ReceiveHeaders();
|
||||
await connection.Receive("Completed");
|
||||
|
||||
await connection.WaitForConnectionClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,6 +306,13 @@ namespace TestSite
|
|||
}
|
||||
}
|
||||
|
||||
private async Task ReadFullBody(HttpContext ctx)
|
||||
{
|
||||
await ReadRequestBody(ctx);
|
||||
ctx.Response.ContentLength = 9;
|
||||
await ctx.Response.WriteAsync("Completed");
|
||||
}
|
||||
|
||||
private async Task WriteManyTimesToResponseBody(HttpContext ctx)
|
||||
{
|
||||
for (var i = 0; i < 10000; i++)
|
||||
|
|
|
|||
Loading…
Reference in New Issue