From 4b443fa069a1d28e8a100c0f5d0b4aac1dfee605 Mon Sep 17 00:00:00 2001 From: granthony <44434533+granthony@users.noreply.github.com> Date: Tue, 17 Jun 2025 15:58:51 +0100 Subject: [PATCH 1/2] Requests.php: always set body This fixes a bug in which response body text satisfying PHP "empty()" is not returned to the caller. Specifically, the response string "0" is not correctly returned. As PHP substr() always returns a string, there is no need for the guard condition here. --- src/Requests.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Requests.php b/src/Requests.php index 761ae8612..ddb339771 100644 --- a/src/Requests.php +++ b/src/Requests.php @@ -739,9 +739,7 @@ protected static function parse_response($headers, $url, $req_headers, $req_data $headers = substr($return->raw, 0, $pos); // Headers will always be separated from the body by two new lines - `\n\r\n\r`. $body = substr($return->raw, $pos + 4); - if (!empty($body)) { - $return->body = $body; - } + $return->body = $body; } // Pretend CRLF = LF for compatibility (RFC 2616, section 19.3) From da20ed79e3f9051bf7511bff9e50d51104ee2015 Mon Sep 17 00:00:00 2001 From: granthony <44434533+granthony@users.noreply.github.com> Date: Mon, 23 Jun 2025 09:15:20 +0100 Subject: [PATCH 2/2] Requests.php: always set body text, if present --- src/Requests.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Requests.php b/src/Requests.php index ddb339771..8dffda713 100644 --- a/src/Requests.php +++ b/src/Requests.php @@ -739,7 +739,9 @@ protected static function parse_response($headers, $url, $req_headers, $req_data $headers = substr($return->raw, 0, $pos); // Headers will always be separated from the body by two new lines - `\n\r\n\r`. $body = substr($return->raw, $pos + 4); - $return->body = $body; + if ($body !== false) { + $return->body = $body; + } } // Pretend CRLF = LF for compatibility (RFC 2616, section 19.3)