Skip to content

Commit 9b42f75

Browse files
authored
Could we avoid allocation of UTF8 byte array? (#692)
1 parent fe7707f commit 9b42f75

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/Giraffe/Core.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,7 @@ module Core =
503503
/// <param name="str">The string value to be send back to the client.</param>
504504
/// <returns>A Giraffe <see cref="HttpHandler" /> function which can be composed into a bigger web application.</returns>
505505
let setBodyFromString (str: string) : HttpHandler =
506-
let bytes = Encoding.UTF8.GetBytes str
507-
fun (_: HttpFunc) (ctx: HttpContext) -> ctx.WriteBytesAsync bytes
506+
fun (_: HttpFunc) (ctx: HttpContext) -> ctx.WriteStringAsync str
508507

509508
/// <summary>
510509
/// 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.

0 commit comments

Comments
 (0)