我目前正在编写一个测试工具,它使用httpd和LUA脚本引入延迟,失败和代理。这包括解析可能包含同一标记的多个值的查询字符串,即:
?ref=12345678&ref=01012052&ref=30257523
然后,这允许消息在消息流中的特定点处延迟,或者将某些请求重定向到备用端点。我的问题在于提供的LUA表中可以使用的内容。
我遇到的问题是,当使用上面的查询字符串之类的代码时,只需注销它正在使用的值:
function output_multi_values(r)
local queryString, queryStringMulti = r:parseargs()
for queryStringKey, queryStringValue in pairs(queryStringMulti) do
r:err(queryStringKey .. "," .. queryString[queryStringKey] .. "," .. tostring(queryStringMulti[queryStringKey]) .. "," .. tostring(queryStringValue))
for multiKey, multiValue in pairs(queryStringMulti[queryStringKey]) do
r:err(queryStringKey .. "," .. multiKey .. "," .. multiValue)
end
end
return 0
end
记录的唯一项目是与提供的最终参考值相关的项目:
[Wed Jun 07 10:24:43.923877 2017] [lua:error] [pid 1370:tid 140336118597376] [client 192.168.56.101:43980] ref,30257523,table: 0x7fa264010810
[Wed Jun 07 10:24:43.923948 2017] [lua:error] [pid 1370:tid 140336118597376] [client 192.168.56.101:43980] ref,1,30257523
正如我们所看到的,在第一个日志条目中,它知道ref的值是一个表,但是当遍历该表时,只返回带有最后一个值的1个条目。此外,标准表也只包括提供的最终值,不确定应该在这里应该是什么而不感兴趣。
我相信我正在遵循mod_lua documentation中概述的parseargs的正确程序,这与我的功能相关,但没有给出如何处理多值部分的示例。
我只是假设它与任何其他表一样工作,其中多值的键是增量整数。
我还有其他方法可以通过多值表进行参考吗?
环境详情
服务器硬件 - Oracle VirtualBox 5.1.16 r113841(2GB RAM,2核CPU,32GB硬盘)。
服务器操作系统 - Ubuntu 16.04.2 LTS(GNU / Linux 4.4.0-78-generic x86_64)。
Apache httpd版本 - 服务器版本:Apache / 2.4.18(Ubuntu),服务器内置:2017-05-05T16:32:00。使用ubuntu规范仓库安装。
Web客户端 - 接受您的选择,而不是依赖客户端(curl,wget,firefox 44,chrome,jmeter)
更多信息
在查询字符串中包含不同的标记会导致所有标记被处理,但是再一次只存储每个标记的最后一个值。查询字符串:
?ref=12345678&ref=01012052&ref=30257523&dob=01062017&dob=0101970
仅导致记录以下内容:
[Wed Jun 07 10:35:15.627686 2017] [lua:error] [pid 1369:tid 140336076633856] [client 192.168.56.101:43982] dob,0101970,table: 0x7fa25c0108f0
[Wed Jun 07 10:35:15.627774 2017] [lua:error] [pid 1369:tid 140336076633856] [client 192.168.56.101:43982] dob,1,0101970
[Wed Jun 07 10:35:15.627786 2017] [lua:error] [pid 1369:tid 140336076633856] [client 192.168.56.101:43982] ref,30257523,table: 0x7fa25c010810
[Wed Jun 07 10:35:15.627795 2017] [lua:error] [pid 1369:tid 140336076633856] [client 192.168.56.101:43982] ref,1,30257523
另外我知道我不应该使用r:err,但它是apache安装的记录级别下降而我无法更改它因此错误确保我得到了日志。
apache2加载了以下模块:
core_module (static)
so_module (static)
watchdog_module (static)
http_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
unixd_module (static)
access_compat_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
filter_module (shared)
lbmethod_bybusyness_module (shared)
lbmethod_byrequests_module (shared)
lbmethod_bytraffic_module (shared)
lbmethod_heartbeat_module (shared)
lua_module (shared)
mime_module (shared)
mpm_event_module (shared)
negotiation_module (shared)
proxy_module (shared)
proxy_ajp_module (shared)
proxy_balancer_module (shared)
proxy_http_module (shared)
setenvif_module (shared)
slotmem_plain_module (shared)
slotmem_shm_module (shared)
socache_shmcb_module (shared)
ssl_module (shared)
status_module (shared)