From f436caa9cbce951a8309f27436ab574e55885017 Mon Sep 17 00:00:00 2001 From: yarroslav Date: Tue, 22 Apr 2014 12:26:46 +0400 Subject: [PATCH] Don't send empty header if don't using zip compression --- UAS/Parser.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/UAS/Parser.php b/UAS/Parser.php index 895463b..20c9145 100755 --- a/UAS/Parser.php +++ b/UAS/Parser.php @@ -457,18 +457,19 @@ protected function getContents($url, $timeout = 300) $starttime = microtime(true); // use fopen if (ini_get('allow_url_fopen')) { + $stream_options = array( + 'http' => array( + 'timeout' => $timeout + ) + ); + if ($this->useZipDownloads) { + $stream_options['http']['header'] = "Accept-Encoding: gzip\r\n"; + } $fp = @fopen( $url, 'rb', false, - stream_context_create( - array( - 'http' => array( - 'timeout' => $timeout, - 'header' => ($this->useZipDownloads ? "Accept-Encoding: gzip\r\n" : "") - ) - ) - ) + stream_context_create($stream_options) ); if (is_resource($fp)) { $data = stream_get_contents($fp);