From 70c490d6ef1f0aa973d21a7279a350f537d28398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Wed, 14 Sep 2016 13:39:53 +0200 Subject: [PATCH] [BridgeAbstract] handle compressed data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- lib/BridgeAbstract.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/BridgeAbstract.php b/lib/BridgeAbstract.php index bfd80de..4fce4bd 100644 --- a/lib/BridgeAbstract.php +++ b/lib/BridgeAbstract.php @@ -364,6 +364,29 @@ abstract class BridgeAbstract implements BridgeInterface { if($content === false) $this->debugMessage('Cant\'t download ' . $url); + // handle compressed data + foreach($http_response_header as $header){ + if(stristr($header, 'content-encoding')){ + switch(true){ + case stristr($header, 'gzip'): + $content = gzinflate( substr($content,10,-8)); + break; + case stristr($header, 'compress'): + //TODO + case stristr($header, 'deflate'): + //TODO + case stristr($header, 'brotli'): + //TODO + returnServerError($header . '=> Not implemented yet'); + break; + case stristr($header, 'identity'): + break; + default: + returnServerError($header . '=> Unknown compression'); + } + } + } + return $content; }