From 20f345593e1273c9d8fb9daf0146371bfa14dbd0 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Tue, 2 Jan 2024 21:05:16 -0500 Subject: [PATCH] [skip ci] small tweak in http client --- playlet-lib/src/source/services/HttpClient.bs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/playlet-lib/src/source/services/HttpClient.bs b/playlet-lib/src/source/services/HttpClient.bs index d2102a15..868820d4 100644 --- a/playlet-lib/src/source/services/HttpClient.bs +++ b/playlet-lib/src/source/services/HttpClient.bs @@ -8,6 +8,8 @@ import "pkg:/source/utils/UrlUtils.bs" namespace HttpClient + const COMPRESSION_ENABLED = true + function Get(url as string) as HttpRequest return (new HttpRequest()).Method("GET").Url(url) end function @@ -188,7 +190,10 @@ namespace HttpClient end if command += ` \\\n --max-time ${m._timeoutSeconds}` - command += ` \\\n --compressed` + + if COMPRESSION_ENABLED + command += ` \\\n --compressed` + end if if m._headers <> invalid for each key in m._headers @@ -385,7 +390,12 @@ namespace HttpClient if urlTransfer = invalid return invalid end if - urlTransfer.EnableEncodings(true) + + if COMPRESSION_ENABLED + ' Enables gzip encoding of transfers + urlTransfer.EnableEncodings(true) + end if + urlTransfer.RetainBodyOnError(true) if LCase(left(m._url, 6)).StartsWith("https:") urlTransfer.SetCertificatesFile("common:/certs/ca-bundle.crt")