gzip on;#开启 gzip_http_version 1.0;#默认1.1 gzip_vary on; gzip_comp_level 6; gzip_proxied any; gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;#压缩的文件类型 gzip_buffers 16 8k;#设置gzip申请内存的大小,其作用是按块大小的倍数申请内存空间设置gzip申请内存的大小,其作用是按块大小的倍数申请内存空间 # Disable gzip for certain browsers. gzip_disable “MSIE [1-6].(?!.*SV1)”;#ie6不支持gzip,需要禁用掉ie6,可恶啊!!!!
local zlib = require "zlib"
local encoding = ngx.req.get_headers()["Content-Encoding"]
if encoding == "gzip" then
local body = ngx.req.get_body_data()
if body then
local stream = zlib.inflate()
ngx.req.set_body_data(stream(body))
end
end
local ffi = require "ffi"
local zlib = require "zlib"
local function reader(s)
local done
return function()
if done then return end
done = true
return s
end
end
local function writer()
local t = {}
return function(data, sz)
if not data then return table.concat(t) end
t[#t + 1] = ffi.string(data, sz)
end
end
local encoding = ngx.req.get_headers()["Content-Encoding"]
if encoding == "gzip" then
local body = ngx.req.get_body_data()
if body then
local write = writer()
zlib.inflate(reader(body), write, nil, "gzip")
ngx.req.set_body_data(write())
end
end
libzlib.so: cannot open shared object file.
local C = ffi.load 'zlib'
local C if ffi.os == "Windows" then C = ffi.load "zlib" else C = ffi.load "z" end
location ~ \.php$ {
access_by_lua_file /path/to/lua/file;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
<?php
$url = 'http://url';
$header = implode("\r\n", array(
'Content-Type: application/x-www-form-urlencoded',
'Content-Encoding: gzip',
'Connection: close',
));
$content = gzencode(http_build_query(array(
'foo' => str_repeat('x', 100),
'bar' => str_repeat('y', 100),
)));
$options = array(
'http' => array(
'protocol_version' => '1.1',
'method' => 'POST',
'header' => $header,
'content' => $content,
),
);
$context = stream_context_create($options);
for ($i = 0; $i < 1000; $i++) {
file_get_contents($url, false, $context);
}
?>
shell> time php /path/to/php/file
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有