From 4a08b8825e64848636d10a0d4cfe91581ec905a0 Mon Sep 17 00:00:00 2001 From: Tuomas Hietanen Date: Sun, 2 Nov 2025 15:38:35 +0000 Subject: [PATCH] Could we avoid allocation of UTF8 byte array? --- src/Giraffe/Core.fs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Giraffe/Core.fs b/src/Giraffe/Core.fs index 765d11c0..35c8afb8 100644 --- a/src/Giraffe/Core.fs +++ b/src/Giraffe/Core.fs @@ -503,8 +503,7 @@ module Core = /// The string value to be send back to the client. /// A Giraffe function which can be composed into a bigger web application. let setBodyFromString (str: string) : HttpHandler = - let bytes = Encoding.UTF8.GetBytes str - fun (_: HttpFunc) (ctx: HttpContext) -> ctx.WriteBytesAsync bytes + fun (_: HttpFunc) (ctx: HttpContext) -> ctx.WriteStringAsync str /// /// Writes an UTF-8 encoded string to the body of the HTTP response and sets the HTTP Content-Length header accordingly, as well as the Content-Type header to text/plain.