|
|
@@ -161,7 +161,9 @@ class Http
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ if(isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE){
|
|
|
+ HttpCache::$gzip = true;
|
|
|
+ }
|
|
|
// Parse $_POST.
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
if (isset($_SERVER['CONTENT_TYPE'])) {
|
|
|
@@ -249,7 +251,10 @@ class Http
|
|
|
$header .= $item . "\r\n";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ if(HttpCache::$gzip && isset($connection->gzip) && $connection->gzip){
|
|
|
+ $header .= "Content-Encoding: gzip\r\n";
|
|
|
+ $content = gzencode($content,$connection->gzip);
|
|
|
+ }
|
|
|
// header
|
|
|
$header .= "Server: workerman/" . Worker::VERSION . "\r\nContent-Length: " . strlen($content) . "\r\n\r\n";
|
|
|
|
|
|
@@ -650,6 +655,7 @@ class HttpCache
|
|
|
*/
|
|
|
public static $instance = null;
|
|
|
public static $header = array();
|
|
|
+ public static $gzip = false;
|
|
|
public static $sessionPath = '';
|
|
|
public static $sessionName = '';
|
|
|
public static $sessionGcProbability = 1;
|