Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion eng/PatchConfig.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ Later on, this will be checked using this condition:
</PropertyGroup>
<PropertyGroup Condition=" '$(VersionPrefix)' == '2.2.2' ">
<PackagesInPatch>
@aspnet/signalr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @BrennanConroy

Intentional removal? We need this if we want to patch NPM packages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad merge.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pakrym You're fixing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Microsoft.AspNetCore.AspNetCoreModuleV2;
Microsoft.AspNetCore.Authentication.Google;
Microsoft.AspNetCore.Http;
Microsoft.AspNetCore.Server.IIS;
</PackagesInPatch>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Servers/IIS/IIS/src/Core/IO/AsyncIOEngine.Read.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public override void FreeOperationResources(int hr, int bytes)
{
_inputHandle.Dispose();
}

protected override bool IsSuccessfulResult(int hr) => hr == NativeMethods.ERROR_HANDLE_EOF;
}
}
}
4 changes: 3 additions & 1 deletion src/Servers/IIS/IIS/src/Core/IO/AsyncIOOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public AsyncContinuation Complete(int hr, int bytes)
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));
Expand All @@ -126,6 +126,8 @@ public AsyncContinuation Complete(int hr, int bytes)
return asyncContinuation;
}

protected virtual bool IsSuccessfulResult(int hr) => false;

public virtual void FreeOperationResources(int hr, int bytes) { }

protected virtual void ResetOperation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ protected override void ResetOperation()

_engine.ReturnOperation(this);
}

protected override bool IsSuccessfulResult(int hr) => hr == NativeMethods.ERROR_HANDLE_EOF;
}
}
}
2 changes: 1 addition & 1 deletion src/Servers/IIS/IIS/src/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class NativeMethods
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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,44 @@ await connection.Receive(
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();
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ private async Task ReadRequestBody(HttpContext ctx)
}
}

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++)
Expand Down