Skip to content

Commit

Permalink
reduced allocations for default path
Browse files Browse the repository at this point in the history
  • Loading branch information
AntyaDev committed Apr 6, 2024
1 parent 971a1c5 commit 8d70f87
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/NBomber.Http/FSharp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,13 @@ module Http =
withJsonBody2 data null req

let sendWithArgs (client: HttpClient) (clientArgs: HttpClientArgs) (request: HttpRequestMessage) = backgroundTask {
do! tryLogRequest(clientArgs, request)
if clientArgs.Logger.IsSome then
do! tryLogRequest(clientArgs, request)

let! response = client.SendAsync(request, clientArgs.HttpCompletion, clientArgs.CancellationToken)
do! tryLogResponse(clientArgs, response)

if clientArgs.Logger.IsSome then
do! tryLogResponse(clientArgs, response)

let reqSize = getRequestSize request
let respSize = getResponseSize response
Expand All @@ -175,9 +179,13 @@ module Http =
/// Send request and deserialize HTTP response JSON body to specified type 'T
/// </summary>
let sendTypedWithArgs<'T> (client: HttpClient) (clientArgs: HttpClientArgs) (request: HttpRequestMessage) = backgroundTask {
do! tryLogRequest(clientArgs, request)
if clientArgs.Logger.IsSome then
do! tryLogRequest(clientArgs, request)

let! response = client.SendAsync(request, clientArgs.HttpCompletion, clientArgs.CancellationToken)
do! tryLogResponse(clientArgs, response)

if clientArgs.Logger.IsSome then
do! tryLogResponse(clientArgs, response)

let reqSize = getRequestSize request
let respSize = getResponseSize response
Expand Down

0 comments on commit 8d70f87

Please sign in to comment.