Skip to content

Commit bccd1ea

Browse files
committed
Merged PR 9014: [2.1] Cancel SendFile copy loops
There are two places in 2.1 where SendFileAsync falls back to a copy loop. These loops should short circuit when the client disconnects, or else the server will sit there and burn resources reading the whole file from disk. Fix: If you passed in your own active CT we'll use it. Otherwise we'll use the RequestAborted token.
1 parent cb4e0ce commit bccd1ea

9 files changed

+200
-33
lines changed

eng/PatchConfig.props

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ Later on, this will be checked using this condition:
6868
</PropertyGroup>
6969
<PropertyGroup Condition=" '$(VersionPrefix)' == '2.1.21' ">
7070
<PackagesInPatch>
71+
Microsoft.AspNetCore.Http.Extensions;
72+
Microsoft.AspNetCore.ResponseCompression;
7173
</PackagesInPatch>
7274
</PropertyGroup>
7375
</Project>

src/Http/Http.Extensions/src/SendFileResponseExtensions.cs

+44-27
Original file line numberDiff line numberDiff line change
@@ -107,41 +107,28 @@ public static Task SendFileAsync(this HttpResponse response, string fileName, lo
107107

108108
private static async Task SendFileAsyncCore(HttpResponse response, IFileInfo file, long offset, long? count, CancellationToken cancellationToken)
109109
{
110-
if (string.IsNullOrEmpty(file.PhysicalPath))
110+
if (!string.IsNullOrEmpty(file.PhysicalPath))
111111
{
112-
CheckRange(offset, count, file.Length);
113-
114-
using (var fileContent = file.CreateReadStream())
115-
{
116-
if (offset > 0)
117-
{
118-
fileContent.Seek(offset, SeekOrigin.Begin);
119-
}
120-
await StreamCopyOperation.CopyToAsync(fileContent, response.Body, count, cancellationToken);
121-
}
112+
await response.SendFileAsync(file.PhysicalPath, offset, count, cancellationToken);
113+
return;
122114
}
123-
else
115+
116+
CheckRange(offset, count, file.Length);
117+
using (var fileContent = file.CreateReadStream())
124118
{
125-
await response.SendFileAsync(file.PhysicalPath, offset, count, cancellationToken);
119+
await SendStreamAsync(fileContent, response, offset, count, cancellationToken);
126120
}
127121
}
128122

129-
private static Task SendFileAsyncCore(HttpResponse response, string fileName, long offset, long? count, CancellationToken cancellationToken = default)
123+
private static async Task SendFileAsyncCore(HttpResponse response, string fileName, long offset, long? count, CancellationToken cancellationToken = default)
130124
{
131125
var sendFile = response.HttpContext.Features.Get<IHttpSendFileFeature>();
132-
if (sendFile == null)
126+
if (sendFile != null)
133127
{
134-
return SendFileAsyncCore(response.Body, fileName, offset, count, cancellationToken);
128+
await sendFile.SendFileAsync(fileName, offset, count, cancellationToken);
129+
return;
135130
}
136131

137-
return sendFile.SendFileAsync(fileName, offset, count, cancellationToken);
138-
}
139-
140-
// Not safe for overlapped writes.
141-
private static async Task SendFileAsyncCore(Stream outputStream, string fileName, long offset, long? count, CancellationToken cancel = default)
142-
{
143-
cancel.ThrowIfCancellationRequested();
144-
145132
var fileInfo = new FileInfo(fileName);
146133
CheckRange(offset, count, fileInfo.Length);
147134

@@ -155,14 +142,44 @@ private static async Task SendFileAsyncCore(Stream outputStream, string fileName
155142
options: FileOptions.Asynchronous | FileOptions.SequentialScan);
156143

157144
using (fileStream)
145+
{
146+
await SendStreamAsync(fileStream, response, offset, count, cancellationToken);
147+
}
148+
}
149+
150+
private static Task SendStreamAsync(Stream source, HttpResponse response, long offset, long? count, CancellationToken cancellationToken)
151+
{
152+
if (!cancellationToken.CanBeCanceled)
153+
{
154+
return SendStreamQuietAsync(source, response, offset, count, response.HttpContext.RequestAborted);
155+
}
156+
157+
cancellationToken.ThrowIfCancellationRequested();
158+
if (offset > 0)
159+
{
160+
source.Seek(offset, SeekOrigin.Begin);
161+
}
162+
163+
return StreamCopyOperation.CopyToAsync(source, response.Body, count, cancellationToken);
164+
}
165+
166+
private static async Task SendStreamQuietAsync(Stream source, HttpResponse response, long offset, long? count, CancellationToken cancellationToken)
167+
{
168+
if (cancellationToken.IsCancellationRequested)
169+
{
170+
return;
171+
}
172+
173+
try
158174
{
159175
if (offset > 0)
160176
{
161-
fileStream.Seek(offset, SeekOrigin.Begin);
177+
source.Seek(offset, SeekOrigin.Begin);
162178
}
163179

164-
await StreamCopyOperation.CopyToAsync(fileStream, outputStream, count, cancel);
180+
await StreamCopyOperation.CopyToAsync(source, response.Body, count, cancellationToken);
165181
}
182+
catch (OperationCanceledException) { }
166183
}
167184

168185
private static void CheckRange(long offset, long? count, long fileLength)
@@ -178,4 +195,4 @@ private static void CheckRange(long offset, long? count, long fileLength)
178195
}
179196
}
180197
}
181-
}
198+
}

src/Http/Http.Extensions/test/Microsoft.AspNetCore.Http.Extensions.Tests.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
55
</PropertyGroup>
66

7+
<ItemGroup>
8+
<Content Include="testfile1kb.txt" CopyToOutputDirectory="PreserveNewest" />
9+
</ItemGroup>
10+
711
<ItemGroup>
812
<Reference Include="Microsoft.AspNetCore.Http" />
913
<Reference Include="Microsoft.AspNetCore.Http.Extensions" />

src/Http/Http.Extensions/test/SendFileResponseExtensionsTests.cs

+42
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information.
22

3+
using System;
34
using System.IO;
45
using System.Threading;
56
using System.Threading.Tasks;
@@ -49,5 +50,46 @@ public Task SendFileAsync(string path, long offset, long? length, CancellationTo
4950
return Task.FromResult(0);
5051
}
5152
}
53+
54+
[Fact]
55+
public async Task SendFile_FallsBackToBodyStream()
56+
{
57+
var body = new MemoryStream();
58+
var context = new DefaultHttpContext();
59+
var response = context.Response;
60+
response.Body = body;
61+
62+
await response.SendFileAsync("testfile1kb.txt", 1, 3, CancellationToken.None);
63+
64+
Assert.Equal(3, body.Length);
65+
}
66+
67+
[Fact]
68+
public async Task SendFile_ThrowsWhenCanceled()
69+
{
70+
var body = new MemoryStream();
71+
var context = new DefaultHttpContext();
72+
var response = context.Response;
73+
response.Body = body;
74+
75+
await Assert.ThrowsAsync<OperationCanceledException>(
76+
() => response.SendFileAsync("testfile1kb.txt", 1, 3, new CancellationToken(canceled: true)));
77+
78+
Assert.Equal(0, body.Length);
79+
}
80+
81+
[Fact]
82+
public async Task SendFile_AbortsSilentlyWhenRequestCanceled()
83+
{
84+
var body = new MemoryStream();
85+
var context = new DefaultHttpContext();
86+
context.RequestAborted = new CancellationToken(canceled: true);
87+
var response = context.Response;
88+
response.Body = body;
89+
90+
await response.SendFileAsync("testfile1kb.txt", 1, 3, CancellationToken.None);
91+
92+
Assert.Equal(0, body.Length);
93+
}
5294
}
5395
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

src/Http/HttpAbstractions.sln

+30
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoutingSample.Web", "Routin
8181
EndProject
8282
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dependencies", "dependencies", "{793FFE24-138A-4C3D-81AB-18D625E36230}"
8383
EndProject
84+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.Kestrel", "..\Servers\Kestrel\Kestrel\src\Microsoft.AspNetCore.Server.Kestrel.csproj", "{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}"
85+
EndProject
86+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IISIntegration", "..\Servers\IIS\IISIntegration\src\Microsoft.AspNetCore.Server.IISIntegration.csproj", "{11E37916-24DF-48A3-AFC9-9E9BB76588E4}"
87+
EndProject
8488
Global
8589
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8690
Debug|Any CPU = Debug|Any CPU
@@ -403,6 +407,30 @@ Global
403407
{F4F5D8AF-FBD1-463F-9473-B63AA820A6C4}.Release|x64.Build.0 = Release|Any CPU
404408
{F4F5D8AF-FBD1-463F-9473-B63AA820A6C4}.Release|x86.ActiveCfg = Release|Any CPU
405409
{F4F5D8AF-FBD1-463F-9473-B63AA820A6C4}.Release|x86.Build.0 = Release|Any CPU
410+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
411+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Debug|Any CPU.Build.0 = Debug|Any CPU
412+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Debug|x64.ActiveCfg = Debug|Any CPU
413+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Debug|x64.Build.0 = Debug|Any CPU
414+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Debug|x86.ActiveCfg = Debug|Any CPU
415+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Debug|x86.Build.0 = Debug|Any CPU
416+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Release|Any CPU.ActiveCfg = Release|Any CPU
417+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Release|Any CPU.Build.0 = Release|Any CPU
418+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Release|x64.ActiveCfg = Release|Any CPU
419+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Release|x64.Build.0 = Release|Any CPU
420+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Release|x86.ActiveCfg = Release|Any CPU
421+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566}.Release|x86.Build.0 = Release|Any CPU
422+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
423+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
424+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Debug|x64.ActiveCfg = Debug|Any CPU
425+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Debug|x64.Build.0 = Debug|Any CPU
426+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Debug|x86.ActiveCfg = Debug|Any CPU
427+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Debug|x86.Build.0 = Debug|Any CPU
428+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
429+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Release|Any CPU.Build.0 = Release|Any CPU
430+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Release|x64.ActiveCfg = Release|Any CPU
431+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Release|x64.Build.0 = Release|Any CPU
432+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Release|x86.ActiveCfg = Release|Any CPU
433+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4}.Release|x86.Build.0 = Release|Any CPU
406434
EndGlobalSection
407435
GlobalSection(SolutionProperties) = preSolution
408436
HideSolutionNode = FALSE
@@ -435,6 +463,8 @@ Global
435463
{E4AC79A3-625B-421B-9F91-EFCBD9BEB37F} = {24D19E8E-25FD-4C0B-8865-697878B67BE0}
436464
{BF8DC0FF-96F9-4705-8CFA-F42BE989AB6A} = {793FFE24-138A-4C3D-81AB-18D625E36230}
437465
{F4F5D8AF-FBD1-463F-9473-B63AA820A6C4} = {14A7B3DE-46C8-4245-B0BD-9AFF3795C163}
466+
{C2608BEB-0C4C-4EDB-A0E4-E29AE59B4566} = {793FFE24-138A-4C3D-81AB-18D625E36230}
467+
{11E37916-24DF-48A3-AFC9-9E9BB76588E4} = {793FFE24-138A-4C3D-81AB-18D625E36230}
438468
EndGlobalSection
439469
GlobalSection(ExtensibilityGlobals) = postSolution
440470
SolutionGuid = {85B5E151-2E9D-419C-83DD-0DDCF446C83A}

src/Middleware/Middleware.sln

+15
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server
191191
EndProject
192192
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_dependencies", "_dependencies", "{ACA6DDB9-7592-47CE-A740-D15BF307E9E0}"
193193
EndProject
194+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IISIntegration", "..\Servers\IIS\IISIntegration\src\Microsoft.AspNetCore.Server.IISIntegration.csproj", "{F05215CF-F754-47BF-ACED-259C53C8B223}"
195+
EndProject
194196
Global
195197
GlobalSection(SolutionConfigurationPlatforms) = preSolution
196198
Debug|Any CPU = Debug|Any CPU
@@ -1005,6 +1007,18 @@ Global
10051007
{260E77CB-800F-4A13-BE92-9CAA097705C2}.Release|x64.Build.0 = Release|Any CPU
10061008
{260E77CB-800F-4A13-BE92-9CAA097705C2}.Release|x86.ActiveCfg = Release|Any CPU
10071009
{260E77CB-800F-4A13-BE92-9CAA097705C2}.Release|x86.Build.0 = Release|Any CPU
1010+
{F05215CF-F754-47BF-ACED-259C53C8B223}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1011+
{F05215CF-F754-47BF-ACED-259C53C8B223}.Debug|Any CPU.Build.0 = Debug|Any CPU
1012+
{F05215CF-F754-47BF-ACED-259C53C8B223}.Debug|x64.ActiveCfg = Debug|Any CPU
1013+
{F05215CF-F754-47BF-ACED-259C53C8B223}.Debug|x64.Build.0 = Debug|Any CPU
1014+
{F05215CF-F754-47BF-ACED-259C53C8B223}.Debug|x86.ActiveCfg = Debug|Any CPU
1015+
{F05215CF-F754-47BF-ACED-259C53C8B223}.Debug|x86.Build.0 = Debug|Any CPU
1016+
{F05215CF-F754-47BF-ACED-259C53C8B223}.Release|Any CPU.ActiveCfg = Release|Any CPU
1017+
{F05215CF-F754-47BF-ACED-259C53C8B223}.Release|Any CPU.Build.0 = Release|Any CPU
1018+
{F05215CF-F754-47BF-ACED-259C53C8B223}.Release|x64.ActiveCfg = Release|Any CPU
1019+
{F05215CF-F754-47BF-ACED-259C53C8B223}.Release|x64.Build.0 = Release|Any CPU
1020+
{F05215CF-F754-47BF-ACED-259C53C8B223}.Release|x86.ActiveCfg = Release|Any CPU
1021+
{F05215CF-F754-47BF-ACED-259C53C8B223}.Release|x86.Build.0 = Release|Any CPU
10081022
EndGlobalSection
10091023
GlobalSection(SolutionProperties) = preSolution
10101024
HideSolutionNode = FALSE
@@ -1086,6 +1100,7 @@ Global
10861100
{0186A5D0-6D05-4C19-BB81-E49A51745FFF} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0}
10871101
{17B7BFF6-4E72-410C-B690-02741505500A} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0}
10881102
{260E77CB-800F-4A13-BE92-9CAA097705C2} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0}
1103+
{F05215CF-F754-47BF-ACED-259C53C8B223} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0}
10891104
EndGlobalSection
10901105
GlobalSection(ExtensibilityGlobals) = postSolution
10911106
SolutionGuid = {83786312-A93B-4BB4-AB06-7C6913A59AFA}

src/Middleware/ResponseCompression/src/BodyWrapperStream.cs

+45-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -286,10 +286,8 @@ public Task SendFileAsync(string path, long offset, long? count, CancellationTok
286286
return _innerSendFileFeature.SendFileAsync(path, offset, count, cancellation);
287287
}
288288

289-
private async Task InnerSendFileAsync(string path, long offset, long? count, CancellationToken cancellation)
289+
private Task InnerSendFileAsync(string path, long offset, long? count, CancellationToken cancellation)
290290
{
291-
cancellation.ThrowIfCancellationRequested();
292-
293291
var fileInfo = new FileInfo(path);
294292
if (offset < 0 || offset > fileInfo.Length)
295293
{
@@ -311,9 +309,25 @@ private async Task InnerSendFileAsync(string path, long offset, long? count, Can
311309
bufferSize: bufferSize,
312310
options: FileOptions.Asynchronous | FileOptions.SequentialScan);
313311

312+
if (cancellation.CanBeCanceled)
313+
{
314+
return InnerSendFileLoudAsync(fileStream, offset, count, cancellation);
315+
}
316+
317+
return InnerSendFileQuietAsync(fileStream, offset, count, _context.RequestAborted);
318+
}
319+
320+
private async Task InnerSendFileLoudAsync(Stream fileStream, long offset, long? count, CancellationToken cancellation)
321+
{
314322
using (fileStream)
315323
{
316-
fileStream.Seek(offset, SeekOrigin.Begin);
324+
cancellation.ThrowIfCancellationRequested();
325+
326+
if (offset > 0)
327+
{
328+
fileStream.Seek(offset, SeekOrigin.Begin);
329+
}
330+
317331
await StreamCopyOperation.CopyToAsync(fileStream, _compressionStream, count, cancellation);
318332

319333
if (_autoFlush)
@@ -322,5 +336,31 @@ private async Task InnerSendFileAsync(string path, long offset, long? count, Can
322336
}
323337
}
324338
}
339+
340+
private async Task InnerSendFileQuietAsync(Stream fileStream, long offset, long? count, CancellationToken cancellation)
341+
{
342+
try
343+
{
344+
if (!cancellation.IsCancellationRequested)
345+
{
346+
if (offset > 0)
347+
{
348+
fileStream.Seek(offset, SeekOrigin.Begin);
349+
}
350+
351+
await StreamCopyOperation.CopyToAsync(fileStream, _compressionStream, count, cancellation);
352+
353+
if (_autoFlush)
354+
{
355+
await _compressionStream.FlushAsync(cancellation);
356+
}
357+
}
358+
}
359+
catch (OperationCanceledException) { }
360+
finally
361+
{
362+
fileStream.Dispose();
363+
}
364+
}
325365
}
326366
}

src/Middleware/ResponseCompression/test/BodyWrapperStreamTests.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -90,6 +90,22 @@ public async Task SendFileAsync_IsPassedToUnderlyingStream_WhenDisableResponseBu
9090
Assert.Equal(File.ReadAllBytes(path), memoryStream.ToArray());
9191
}
9292

93+
[Fact]
94+
public async Task SendFileAsync_SkipsSilently_WhenRequestAborted()
95+
{
96+
var memoryStream = new MemoryStream();
97+
98+
var context = new DefaultHttpContext();
99+
context.RequestAborted = new CancellationToken(canceled: true);
100+
var stream = new BodyWrapperStream(context, memoryStream, new MockResponseCompressionProvider(true), null, null);
101+
102+
var path = "testfile1kb.txt";
103+
await stream.SendFileAsync(path, 0, null, CancellationToken.None);
104+
stream.Flush();
105+
106+
Assert.Equal(0, memoryStream.Length);
107+
}
108+
93109
[Theory]
94110
[InlineData(true)]
95111
[InlineData(false)]

0 commit comments

Comments
 (0)