diff --git a/src/RestSharp/RestClient.Async.cs b/src/RestSharp/RestClient.Async.cs index ed7b502fa..8eadd5bb3 100644 --- a/src/RestSharp/RestClient.Async.cs +++ b/src/RestSharp/RestClient.Async.cs @@ -95,6 +95,8 @@ record InternalResponse(HttpResponseMessage? ResponseMessage, Uri Url, Exception /// The downloaded stream. [PublicAPI] public async Task DownloadStreamAsync(RestRequest request, CancellationToken cancellationToken = default) { + // Make sure we only read the headers so we can stream the content body efficiently + request.CompletionOption = HttpCompletionOption.ResponseHeadersRead; var response = await ExecuteInternal(request, cancellationToken).ConfigureAwait(false); if (response.Exception != null) { diff --git a/src/RestSharp/RestClientExtensions.cs b/src/RestSharp/RestClientExtensions.cs index 501964d4c..22ac300da 100644 --- a/src/RestSharp/RestClientExtensions.cs +++ b/src/RestSharp/RestClientExtensions.cs @@ -331,7 +331,7 @@ public static async IAsyncEnumerable StreamJsonAsync( string resource, [EnumeratorCancellation] CancellationToken cancellationToken ) { - var request = new RestRequest(resource) { CompletionOption = HttpCompletionOption.ResponseHeadersRead }; + var request = new RestRequest(resource); #if NETSTANDARD using var stream = await client.DownloadStreamAsync(request, cancellationToken).ConfigureAwait(false);