-
Notifications
You must be signed in to change notification settings - Fork 480
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
Failed to read stream from HttpClient.Get with option HttpCompletionOption.ResponseHeadersRead #255
Comments
Worked for me class Program
{
static void Main(string[] args)
{
Test().Wait();
}
public static async Task Test()
{
using(var client = new HttpClient())
using (var response = await client.GetAsync("https://github.com/adamhathcock/sharpcompress/raw/master/tests/TestArchives/Archives/Tar.tar",
HttpCompletionOption.ResponseHeadersRead))
{
var stream = await response.Content.ReadAsStreamAsync();
using (var reader = ReaderFactory.Open(stream))
{
reader.MoveToNextEntry();
reader.WriteEntryTo(new MemoryStream()); //System
}
}
}
} Always use |
This |
Weird. Just in case I put my code here: https://github.com/adamhathcock/sc-http-test |
git clone & dotnet run still get the same exception.
|
I created an issue https://github.com/dotnet/corefx/issues/20676. public override int Read(byte[] buffer, int offset, int count)
{
if (count == 0)
{
return 0;
} |
I don't get how I didn't get the exception but you did. Just happened to read zero bytes and I didn't? |
This issue occurs only on windows, Are you using macOS or Linux? |
You're right. I get this on Windows but not macOS |
thanks. |
The following code works fine under full framework, but get exception under .net core 1.0 and 2.0.
Changing the HttpClient.Get option to
HttpCompletionOption.ResponseContentRead
also works. But for large files, it can not start decompressing until the entire file is downloaded.The text was updated successfully, but these errors were encountered: