From 57f270755ae6d24bdd58263273ee5ca76627f7de Mon Sep 17 00:00:00 2001 From: Wardiyono Date: Tue, 9 Mar 2021 09:58:47 +0700 Subject: [PATCH] Fix msg error while sending to UCS The fix is based on Bulian version by @idoalit --- lib/http_request.inc.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/http_request.inc.php b/lib/http_request.inc.php index 6e9e96cf..c533b5c8 100755 --- a/lib/http_request.inc.php +++ b/lib/http_request.inc.php @@ -186,6 +186,16 @@ public function send_http_request($url, $referer, $data, $method = 'POST', $cont $result = explode("\r\n\r\n", $result, 2); $this->headers = isset($result[0]) ? $result[0] : ''; - $this->body = isset($result[1]) ? $result[1] : ''; + $this->body = $this->decode_chunked(isset($result[1]) ? $result[1] : ''); + } + + function decode_chunked($str) { + for ($res = ''; !empty($str); $str = trim($str)) { + $pos = strpos($str, "\r\n"); + $len = hexdec(substr($str, 0, $pos)); + $res.= substr($str, $pos + 2, $len); + $str = substr($str, $pos + 2 + $len); + } + return $res; } }