From ea7751af9eb07403d3b32767cb5bf0e0c3f35a6a Mon Sep 17 00:00:00 2001 From: "princemelvin@microsoft.com" Date: Mon, 11 Dec 2023 23:10:07 +0530 Subject: [PATCH] Fixed response failure for unsupported encoding --- locust/contrib/fasthttp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locust/contrib/fasthttp.py b/locust/contrib/fasthttp.py index 1b67111276..071bbe4a93 100644 --- a/locust/contrib/fasthttp.py +++ b/locust/contrib/fasthttp.py @@ -378,7 +378,7 @@ def rest( with self.client.request(method, url, catch_response=True, headers=headers, **kwargs) as r: resp = cast(RestResponseContextManager, r) resp.js = None # type: ignore - if resp.text is None: + if resp.content is None: resp.failure(str(resp.error)) elif resp.text: try: @@ -467,8 +467,8 @@ def text(self) -> Optional[str]: # No information, try to detect if not self.encoding: self.encoding = str(detect(self.content)["encoding"]) - - return str(self.content, self.encoding, errors="replace") + if self.encoding != "None": + return str(self.content, self.encoding, errors="replace") @property def url(self) -> Optional[str]: