Skip to content
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

Stop copying content stream in .NET MAUI Blazor Windows #9254

Merged
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
9 changes: 1 addition & 8 deletions src/BlazorWebView/src/Maui/Windows/WinUIWebViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,8 @@ protected override async Task HandleWebResourceRequest(CoreWebView2WebResourceRe
if (TryGetResponseContent(requestUri, allowFallbackOnHostPage, out var statusCode, out var statusMessage, out var content, out var headers)
&& statusCode != 404)
{
// NOTE: This is stream copying is to work around a hanging bug in WinRT with managed streams.
// See issue https://github.com/microsoft/CsWinRT/issues/670
var memStream = new MemoryStream();
content.CopyTo(memStream);
var ms = new InMemoryRandomAccessStream();
await ms.WriteAsync(memStream.GetWindowsRuntimeBuffer());

var headerString = GetHeaderString(headers);
eventArgs.Response = _coreWebView2Environment!.CreateWebResourceResponse(ms, statusCode, statusMessage, headerString);
eventArgs.Response = _coreWebView2Environment!.CreateWebResourceResponse(content.AsRandomAccessStream(), statusCode, statusMessage, headerString);
}
else if (new Uri(requestUri) is Uri uri && AppOriginUri.IsBaseOf(uri))
{
Expand Down