Very similar to https://github.com/aspnet/KestrelHttpServer/issues/2341 (PR https://github.com/aspnet/KestrelHttpServer/pull/2342) the ReferenceReadStream does throw a NotSupportedException in its Flush method when it should not.
using(var cs = new CryptoStream(formFile.OpenReadStream(), ...))
{
throw new Exception("stream has not been read completely and therefore CryptoStream will call Flush");
}
This should not trigger a NotSupportedException.
Seems reasonable to just no-op in Flush instead of throwing.
The simplest workaround you can use for now (and in 2.1, since the change would be in 5.0) would be to build your own wrapper that forwards all calls to the inner stream except Flush and then wrap that around ReferenceReadStream.
A pity it's not backported, but I guess the workaround is good enough. Thank you for the quick response.
Most helpful comment
Seems reasonable to just no-op in
Flushinstead of throwing.The simplest workaround you can use for now (and in 2.1, since the change would be in 5.0) would be to build your own wrapper that forwards all calls to the inner stream except
Flushand then wrap that aroundReferenceReadStream.