From 81891360f6e21cf5e9b4f291943729b44787c162 Mon Sep 17 00:00:00 2001 From: Kyle Taylor Date: Thu, 6 Jul 2023 11:15:47 -0500 Subject: [PATCH 1/2] Fix content-type cleaning if provided an array --- src/helpers.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/helpers.php b/src/helpers.php index 83e66d9..cdbc4b9 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -2,12 +2,17 @@ use Proxy\Config; -// strip away extra parameters text/html; charset=UTF-8 -function clean_content_type($content_type){ - return trim(preg_replace('@;.*@', '', $content_type)); +/** + * Strip away extra parameters "text/html; charset=UTF-8" + * @param $content_type + * @return string + */ +function clean_content_type($content_type) +{ + $content_type = (is_array($content_type) && count($content_type) > 0) ? $content_type[0] : $content_type; + return trim(preg_replace('@;.*@', '', $content_type)); } - if(!function_exists('starts_with')){ function starts_with($haystack, $needles){ From 3b52a698a83755c13c0af2bd829e55678d6a1762 Mon Sep 17 00:00:00 2001 From: Kyle Taylor Date: Thu, 6 Jul 2023 11:31:27 -0500 Subject: [PATCH 2/2] Overwrite header if it already exists. --- src/Proxy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Proxy.php b/src/Proxy.php index 152b256..e950493 100644 --- a/src/Proxy.php +++ b/src/Proxy.php @@ -46,7 +46,7 @@ private function header_callback($ch, $headers){ $value = trim($parts[1]); // this must be a header: value line - $this->response->headers->set($name, $value, false); + $this->response->headers->set($name, $value, true); } else if($this->status_found){