Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Client/Internal/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ public async Task<Stream> AsStream()
#endif
)
.ConfigureAwait(false);
stream.Position = 0;

if (stream.CanSeek)
stream.Position = 0;

return stream;
}

Expand Down
18 changes: 18 additions & 0 deletions Tests/Integration/IntegrationTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq.Expressions;
#if NET452
using System.Net;
#endif
using System.Net.Http;
using System.Threading.Tasks;
using NUnit.Framework;
using Pathoschild.Http.Client;
Expand Down Expand Up @@ -53,6 +55,22 @@ public class IntegrationTests
/*********
** Unit tests
*********/
[Test(Description = "The client can stream a large file.")]
public async Task StreamLargeFile()
{
// arrange
IClient client = this.ConstructClient("https://proof.ovh.net/");

// act
Stream result = await client
.GetAsync("files/1Mb.dat") // Files of various sizes are available for testing purposes. See this article: https://www.buildsometech.com/download-test-files/#Download_Test_Files_100GB_50GB_10GB_5GB_4GB_2GB_1GB_High-Speed
.WithOptions(completeWhen: HttpCompletionOption.ResponseHeadersRead)
.AsStream();

// assert
Assert.IsNotNull(result);
}

[Test(Description = "The client can fetch a resource from the English Wikipedia's API.")]
public async Task EnglishWikipedia()
{
Expand Down