Skip to content

Http.Sys request body does not support 0-byte reads #41305

Closed
@Tratcher

Description

@Tratcher

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

RE: dotnet/yarp#1665

YARP now uses a zero-byte read optimization when copying the request body. Http.Sys's request body stream throws an argument exception when passed a zero length buffer.

Expected Behavior

The request body stream should allow zero length buffer, wait until data is available, and then return.

Steps To Reproduce

No response

Exceptions (if any)

Error Message: (Parameter 'size') Actual value was 0.

CallStack:
at Microsoft.AspNetCore.Server.HttpSys.RequestStream.ValidateReadBuffer(Byte[] buffer, Int32 offset, Int32 size)
at Microsoft.AspNetCore.Server.HttpSys.RequestStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 size, CancellationToken cancellationToken)
at System.IO.Stream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
at Yarp.ReverseProxy.Forwarder.StreamCopier.d__3.MoveNext() in D:GItRepo\reverse-proxy\src\ReverseProxy\Forwarder\StreamCopier.cs:line 53

.NET Version

6.0

Anything else?

Recommended servicing in 6.0.

Metadata

Metadata

Assignees

Labels

area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsbugThis issue describes a behavior which is not expected - a bug.feature-httpsys

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions