Use "application/wasm" media type for .wasm files to enable streaming compilation

This commit is contained in:
Steve Sanderson 2018-02-28 15:19:08 +00:00
parent e3b995b933
commit 1d07783522
4 changed files with 31 additions and 7 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Blazor.Server;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
@ -21,8 +22,11 @@ namespace Microsoft.AspNetCore.Blazor.Cli.Server
services.AddRouting();
services.AddResponseCompression(options =>
{
options.MimeTypes = ResponseCompressionDefaults.MimeTypes
.Concat(new[] { MediaTypeNames.Application.Octet });
options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[]
{
MediaTypeNames.Application.Octet,
WasmMediaTypeNames.Application.Wasm
});
});
}

View File

@ -7,7 +7,6 @@ using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.FileProviders;
using System.IO;
using System.Net.Mime;
using System.Reflection;
namespace Microsoft.AspNetCore.Builder
{
@ -81,7 +80,7 @@ namespace Microsoft.AspNetCore.Builder
var result = new FileExtensionContentTypeProvider();
result.Mappings.Add(".dll", MediaTypeNames.Application.Octet);
result.Mappings.Add(".mem", MediaTypeNames.Application.Octet);
result.Mappings.Add(".wasm", MediaTypeNames.Application.Octet);
result.Mappings.Add(".wasm", WasmMediaTypeNames.Application.Wasm);
return result;
}
}

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Builder
{

View File

@ -0,0 +1,22 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Blazor.Server
{
/// <summary>
/// Contains values for WASM-related media types.
/// </summary>
public static class WasmMediaTypeNames
{
/// <summary>
/// Contains values for WASM-related media types within the "application." namespace
/// </summary>
public static class Application
{
/// <summary>
/// The standard media type name for WebAssembly binary files.
/// </summary>
public const string Wasm = "application/wasm";
}
}
}