小编mat*_*129的帖子

MD5 $request_body

我正在使用 nginx(和 OpenResty)并尝试$request_body对缓存进行哈希处理(使用srcache)。

当试图做到echo$request_body,它完美的作品:

# actually echoes the request body
location /works {
    # force loading the body
    echo_read_request_body;

    echo $request_body;
}
Run Code Online (Sandbox Code Playgroud)

但是当试图计算 md5 时,我得到了一个空字符串的 MD5,尽管我确保它$request_body是通过echo_read_request_body;.

# echoes d41d8cd98f00b204e9800998ecf8427e, which is the MD5 for empty input.
location /doesnt-work-md5 {
    # force loading the body
    echo_read_request_body;

    set_md5 $digest $request_body;
    echo $digest;
}
Run Code Online (Sandbox Code Playgroud)

最奇怪的现象是,在尝试复制变量时它甚至不起作用:

# echoes nothing - empty data
location /doesnt-work {
    # force loading the body …
Run Code Online (Sandbox Code Playgroud)

nginx cache

2
推荐指数
1
解决办法
3151
查看次数

标签 统计

cache ×1

nginx ×1