Skip to content

Commit 2673ba7

Browse files
committed
Fixes #47
Workaround for dotnet/corefx#9071
1 parent 08b4495 commit 2673ba7

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/FubarDev.WebDavServer/Handlers/Impl/GetResults/WebDavFullDocumentResult.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,23 @@ public override async Task ExecuteResultAsync(IWebDavResponse response, Cancella
6464

6565
using (var stream = await _document.OpenReadAsync(ct).ConfigureAwait(false))
6666
{
67-
var content = new StreamContent(stream);
68-
await SetPropertiesToContentHeaderAsync(content, properties, ct).ConfigureAwait(false);
69-
70-
foreach (var header in content.Headers)
71-
response.Headers.Add(header.Key, header.Value.ToArray());
72-
73-
await content.CopyToAsync(response.Body).ConfigureAwait(false);
67+
using (var content = new StreamContent(stream))
68+
{
69+
// I'm storing the headers in the content, because I'm too lazy to
70+
// look up the header names and the formatting of its values.
71+
await SetPropertiesToContentHeaderAsync(content, properties, ct).ConfigureAwait(false);
72+
73+
foreach (var header in content.Headers)
74+
{
75+
response.Headers.Add(header.Key, header.Value.ToArray());
76+
}
77+
78+
// Use the CopyToAsync function of the stream itself, because
79+
// we're able to pass the cancellation token. This is a workaround
80+
// for issue dotnet/corefx#9071 and fixes FubarDevelopment/WebDavServer#47.
81+
await stream.CopyToAsync(response.Body, 81920, ct)
82+
.ConfigureAwait(false);
83+
}
7484
}
7585
}
7686

0 commit comments

Comments
 (0)