Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched to rent an array in Giraffe handler #469

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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