Skip to content

Commit

Permalink
Switched to rent an array in Giraffe handler
Browse files Browse the repository at this point in the history
  • Loading branch information
xperiandri committed Mar 24, 2024
1 parent 713d807 commit e8548c2
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace FSharp.Data.GraphQL.Server.AspNetCore.Giraffe

open System
open System.Buffers
open System.IO
open System.Text.Json
open System.Text.Json.Serialization
Expand Down Expand Up @@ -154,10 +155,13 @@ module HttpHandlers =
else
request.EnableBuffering()
let body = request.Body
let buffer = Array.zeroCreate 1
let! bytesRead = body.ReadAsync(buffer, 0, 1)
body.Seek(0, SeekOrigin.Begin) |> ignore
return bytesRead > 0
let buffer = ArrayPool.Shared.Rent 1
try
let! bytesRead = body.ReadAsync(buffer, 0, 1)
body.Seek(0, SeekOrigin.Begin) |> ignore
return bytesRead > 0
finally
ArrayPool.Shared.Return buffer
}

/// <summary>Check if the request is an introspection query
Expand Down

0 comments on commit e8548c2

Please sign in to comment.