From fb8443fd25ac84ddb4aa24b13ed38f3a83a001c8 Mon Sep 17 00:00:00 2001 From: Aykhan Shahsuvarov Date: Tue, 29 Sep 2026 23:40:57 +0400 Subject: [PATCH] chore: read response headers into a 64KiB buffer instead of 4KiB --- internal/sarin/client.go | 2 ++ internal/sarin/scripthttp.go | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/sarin/client.go b/internal/sarin/client.go index beaf5af..861105e 100644 --- a/internal/sarin/client.go +++ b/internal/sarin/client.go @@ -61,6 +61,7 @@ func NewHostClients( ReadTimeout: timeout, MaxResponseBodySize: safeUint64ToInt(maxResponseBody), MaxIdemponentCallAttempts: 1, + ReadBufferSize: 64 << 10, // 64 KiB DisableHeaderNamesNormalizing: true, DisablePathNormalizing: true, NoDefaultUserAgentHeader: true, @@ -85,6 +86,7 @@ func NewHostClients( ReadTimeout: timeout, MaxResponseBodySize: safeUint64ToInt(maxResponseBody), MaxIdemponentCallAttempts: 1, + ReadBufferSize: 64 << 10, // 64 KiB DisableHeaderNamesNormalizing: true, DisablePathNormalizing: true, NoDefaultUserAgentHeader: true, diff --git a/internal/sarin/scripthttp.go b/internal/sarin/scripthttp.go index 285b485..614c822 100644 --- a/internal/sarin/scripthttp.go +++ b/internal/sarin/scripthttp.go @@ -56,11 +56,11 @@ func newScriptHTTPClient( // Read and write timeouts stay unset because they would cap the per-call timeout, // so dialWithDeadline is what bounds the TLS handshake. return &fasthttp.Client{ - DialTimeout: dialWithDeadline(dial), - MaxConnsPerHost: safeUintToInt(maxConns), - MaxResponseBodySize: safeUint64ToInt(maxResponseBody), - // Retries would send one script call several times and hide it from the results. + DialTimeout: dialWithDeadline(dial), + MaxConnsPerHost: safeUintToInt(maxConns), + MaxResponseBodySize: safeUint64ToInt(maxResponseBody), MaxIdemponentCallAttempts: 1, + ReadBufferSize: 64 << 10, // 64 KiB TLSConfig: &tls.Config{ InsecureSkipVerify: insecure, //nolint:gosec },