Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestHost response body does not support 0-byte reads #41692

Open
1 task done
MihaZupan opened this issue May 16, 2022 · 0 comments
Open
1 task done

TestHost response body does not support 0-byte reads #41692

MihaZupan opened this issue May 16, 2022 · 0 comments
Labels
bug

Comments

@MihaZupan
Copy link
Member

@MihaZupan MihaZupan commented May 16, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Similar to #41287 and #41305, TestHost also doesn't expect/support 0-byte reads on the body.

if (count <= 0 || count > buffer.Length - offset)
{
throw new ArgumentOutOfRangeException(nameof(count), count, string.Empty);
}

Expected Behavior

The 0-byte read should not throw and subsequent reads should return available data.

Steps To Reproduce

See yarp.zip (repro attached in the original Yarp issue)

Exceptions (if any)

Yarp.ReverseProxy.Forwarder.HttpForwarder[48]
ResponseBodyDestination: The destination reported an error when copying the response body.
System.ArgumentOutOfRangeException: (Parameter 'count')
Actual value was 0.
at Microsoft.AspNetCore.TestHost.ResponseBodyReaderStream.VerifyBuffer(Byte[] buffer, Int32 offset, Int32 count)
at Microsoft.AspNetCore.TestHost.ResponseBodyReaderStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at Yarp.ReverseProxy.Forwarder.StreamCopier.CopyAsync(Stream input, Stream output, Int64 promisedContentLength, StreamCopierTelemetry telemetry, ActivityCancellationTokenSource activityToken, CancellationToken cancellation)

.NET Version

6.0.5

Anything else?

Discovered by a user writing unit tests that include Yarp microsoft/reverse-proxy#1720

cc: @Tratcher @adityamandaleeka

There kind of failures can be caught by StreamConformanceTests we run in runtime.
For example, here are 0-byte read tests for HttpClient response streams.
Are there any plans to include such tests in AspNetCore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug
Projects
None yet
Development

No branches or pull requests

1 participant