Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
lua:`zlib`与HTTP不兼容?_Lua_Gzip - Fatal编程技术网

lua:`zlib`与HTTP不兼容?

lua:`zlib`与HTTP不兼容?,lua,gzip,Lua,Gzip,我正在使用wrk测试我的HTTP服务器,因此Lua是构建HTTP主体的首选脚本 使用lua的zlib软件包时: zlib = require 'zlib' md5 = require 'md5' x = zlib.deflate(5,31)("abcdefghigklmn", "finish") print(md5.sumhexa(x)) 我得到了f2fa3c8e97506f0d6e27248a82b9b76d,但是当使用golang的gzip(我在我的客户机和服务器中使用过,它与HTTP兼容

我正在使用
wrk
测试我的HTTP服务器,因此Lua是构建HTTP主体的首选脚本

使用lua的
zlib
软件包时:

zlib = require 'zlib'
md5 = require 'md5'
x = zlib.deflate(5,31)("abcdefghigklmn", "finish")
print(md5.sumhexa(x))
我得到了
f2fa3c8e97506f0d6e27248a82b9b76d
,但是当使用golang的
gzip
(我在我的客户机和服务器中使用过,它与HTTP兼容),我得到了不同的值
34b6ba0659ded8aa506e07afc01dd1df8

import (
    "bytes"
    "fmt"
    "crypto/md5"
    "compress/gzip"
    "encoding/hex"
)

var buf bytes.Buffer
g := gzip.NewWriter(&buf)
g.Write([]byte{"abcdefghigklmn"})
h := md5.New()
h.Write(buf.Bytes())
fmt.Printf("%s", hex.EncodeToString(h.Sum(nil)))

是否有其他lua的
gzip
实现与httpgzip兼容

是的,
zip
gzip
是不同的格式(压缩方法是相同的,但归档头是相同的)。我使用pegasus服务器,它使用lua zlib/lzlib库来压缩gzip。