From 6550a678de860157d4bb4fda6bc988a5f0e8e3e9 Mon Sep 17 00:00:00 2001 From: Web Addicto Date: Sat, 28 Oct 2017 00:43:24 +0200 Subject: [PATCH] Better content-type check (updated to v5.0.5) Updated PR https://github.com/Athlon1600/php-proxy/pull/37 by JClerc to have no conflicts with the base branch. --- src/Plugin/ProxifyPlugin.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Plugin/ProxifyPlugin.php b/src/Plugin/ProxifyPlugin.php index 0d29cdf..f294800 100644 --- a/src/Plugin/ProxifyPlugin.php +++ b/src/Plugin/ProxifyPlugin.php @@ -142,13 +142,16 @@ public function onCompleted(ProxyEvent $event){ $this->base_url = $event['request']->getUri(); $response = $event['response']; - $content_type = $response->headers->get('content-type'); + $content_type = strtolower(trim($response->headers->get('content-type'))); $str = $response->getContent(); // DO NOT do any proxification on .js files and text/plain content type - if($content_type == 'text/javascript' || $content_type == 'application/javascript' || $content_type == 'application/x-javascript' || $content_type == 'text/plain'){ - return; + // Support also resource like Content-Type: text/javascript;charset=UTF-8 + foreach(array('text/javascript', 'application/javascript', 'application/x-javascript', 'text/plain') as $type){ + if(strpos($content_type, $type) === 0){ + return; + } } // remove JS from urls