lua-ffi-zlib icon indicating copy to clipboard operation
lua-ffi-zlib copied to clipboard

INFLATE: data error

Open poembro opened this issue 5 years ago • 0 comments

my code

function _M:inflategzip(is_zip, zip_total_size, body)
    if is_zip and is_zip == true then  
        local chunk = 16384 
        local output_table = {}  
        local count = 0
        
        local input = function(bufsize)  
            local start = count > 0 and bufsize*count or 1  
            local datas = body:sub(start, (bufsize*(count+1)-1) )  
            count = count + 1
            return datas
        end  
        
        local output_table = {}  
        local output = function(data)  
            table_insert(output_table, data)  
        end
        
        local ok, err = zlib.inflateGzip(input, output, chunk)
        if not ok then  
             ngx.log(ngx.ERR, "--> zlib error---- ", err)
        end
        
        body = table_concat(output_table,'')  
        
        if  string_len(body) ~= zip_total_size then
            ngx.log(ngx.ERR, "-->  error 2---- ", err)
        end 
        return body
    end
    
    return body
end

nginx_error.log 文件中出现

2018/10/26 19:11:16 [error] 6411#0: *2631471 [lua] soft.lua:179: inflategzip(): --> zlib error---- INFLATE: data error, client: 106.32.216.112, server: -, request: "GET /socket?order=23243 HTTP/1.1", host: "gamewaf.23af.com"

poembro avatar Oct 26 '18 11:10 poembro