diff --git a/Modules/Pages/Extensions.cs b/Modules/Pages/Extensions.cs index 85f80ccb..5e0f10f1 100644 --- a/Modules/Pages/Extensions.cs +++ b/Modules/Pages/Extensions.cs @@ -7,7 +7,7 @@ namespace GenHTTP.Modules.Pages; public static class Extensions { - private static readonly ByteString HtmlContentType = new("text/html; charset=\"utf-8\""); + private static readonly ContentType HtmlContentType = new("text/html; charset=\"utf-8\""); /// /// Creates a response that can be returned by a handler to serve @@ -17,8 +17,7 @@ public static class Extensions /// The HTML page to be served /// The HTML page response public static IResponseBuilder GetPage(this IRequest request, string content) => request.Respond() - .Content(new StringContent(content)) - .Header(KnownHeaders.ContentType, HtmlContentType); + .Content(new StringContent(content, HtmlContentType)); /// /// Escapes the given string so it can safely be used in HTML. diff --git a/Testing/Acceptance/Modules/ApiBrowsing/ApplicationTests.cs b/Testing/Acceptance/Modules/ApiBrowsing/ApplicationTests.cs index 1d55a10c..a7c8a6b8 100644 --- a/Testing/Acceptance/Modules/ApiBrowsing/ApplicationTests.cs +++ b/Testing/Acceptance/Modules/ApiBrowsing/ApplicationTests.cs @@ -62,6 +62,8 @@ public async Task TestScalar(ServerEngine engine) await response.AssertStatusAsync(HttpStatusCode.OK); + Assert.AreEqual("text/html", response.Content.Headers.ContentType?.MediaType); + AssertX.Contains("Scalar", await response.GetContentAsync()); }