Skip to content

Commit 5650542

Browse files
committed
Could we avoid allocation of UTF8 byte array?
1 parent c00ace4 commit 5650542

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/Giraffe/Core.fs

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

441440
/// <summary>
442441
/// 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)