From e4ba86944438e175c22806b8b4525643acce5a84 Mon Sep 17 00:00:00 2001 From: "Emanuele \"ToX\" Toscano" Date: Fri, 3 Nov 2017 10:24:25 +0100 Subject: [PATCH] Fix closure-compiler's "redirection limit reached" Since a few days, the js minification was complaining about a redirection limit in the closure-compiler call. This was generating an error each time I have tried to use this tool. After a bit of investigation I have found out that it was missing some parameters that are now mandatory. Plus, it now works in https only. --- min/lib/Minify/JS/ClosureCompiler.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/min/lib/Minify/JS/ClosureCompiler.php b/min/lib/Minify/JS/ClosureCompiler.php index e067d7c8..96e91c9c 100644 --- a/min/lib/Minify/JS/ClosureCompiler.php +++ b/min/lib/Minify/JS/ClosureCompiler.php @@ -53,7 +53,7 @@ class Minify_JS_ClosureCompiler { /** * @var string $url URL of compiler server. defaults to Google's */ - protected $serviceUrl = 'http://closure-compiler.appspot.com/compile'; + protected $serviceUrl = 'https://closure-compiler.appspot.com/compile'; /** * @var int $maxBytes The maximum JS size that can be sent to the compiler server in bytes @@ -172,6 +172,9 @@ protected function getResponse($postBody) $contents = file_get_contents($this->serviceUrl, false, stream_context_create(array( 'http' => array( 'method' => 'POST', + 'compilation_level' => 'SIMPLE', + 'output_format' => 'text', + 'output_info' => 'compiled_code', 'header' => "Content-type: application/x-www-form-urlencoded\r\nConnection: close\r\n", 'content' => $postBody, 'max_redirects' => 0,