You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Response.AsStream attempts to rewind the stream even when it's not "seekable" #125
There are scenarios where a stream is marked as not "seekable" which means that we cannot manually change the position pointer like so: myStream.Position = 0;. Unfortunately, the AsStream method in the Response class does not take this scenario into consideration and it attempts to systematically rewind all streams (when I say "rewind", I mean: set the position pointer to zero) here.
This issue was discovered while testing the new streaming option discussed in #123 and introduced in v4.4.0. When the content of a stream is being streamed, the position pointer cannot be manually changed. To make the situation more confusing, the exception thrown when you attempt to reposition the pointer in a non-seekable stream is not clear at all: Specified method is not supported.
Here's an integration test to reproduce the problem:
[Test(Description="The client can stream a large file.")]publicasyncTaskStreamLargeFile(){// arrangeIClientclient=this.ConstructClient("https://proof.ovh.net/");// actvarresult=awaitclient.GetAsync("files/1Mb.dat").WithOptions(completeWhen:HttpCompletionOption.ResponseHeadersRead).AsStream();}
I will submit a PR with a fix to ensure Response.AsStream does not attempt to reposition a non-seekable stream.
If you could publish a hotfix, that would be much appreciated.
Activity
Only reposition streams that are "seekable"
Pathoschild commentedon Jun 6, 2024
#126 merged into
developand released in FluentHttpClient 4.4.1. Thanks for the help!Jericho commentedon Jun 6, 2024
Awesome! Thank you.