I am currently writing a test harness that introduces delays, failures and proxying using httpd with LUA scripts. This includes the parsing of the querystring which could contain multiple values for the same tag ie:
?ref=12345678&ref=01012052&ref=30257523
This then allows the message to be delayed at specific points in the message flow or redirect certain requests to an alternative endpoint. My problem comes with what is available to work with in the LUA tables provided.
The problem I am having is that when using something like the below code with the above querystring to simply log out which values it is working with:
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
the only items logged are those relevant for the final ref value provided:
[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
As we can see, in the first log entry, it knows the value for ref is a table, but when iterating through that table only returns 1 entry with the last value provided. Also, the standard table also only includes the final value provided, not sure what should be here though and not interested.
I believe I am following the correct procedure for parseargs as outlined in the mod_lua documentation which echoes my expectations as far as my function is concerned but gives no example of how to process the multivalue part.
I just assumed it worked the same as any other table with the keys for the multivalue being incremental integers.
Is there some other way I should be going through the multivalue table for ref?
Environment details
Server hardware - Oracle VirtualBox 5.1.16 r113841 (2gb RAM, 2 core CPU, 32gb hdd).
Server OS - Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-78-generic x86_64).
Apache httpd version - Server version: Apache/2.4.18 (Ubuntu), Server built: 2017-05-05T16:32:00. Installed using the ubuntu canonical repo.
Web client - take your pick, not client dependant (curl, wget, firefox 44, chrome, jmeter)
A bit more info
Including different tags in the query string results in all tags being processed but once again, only the last value for each tag being stored. Querystring:
?ref=12345678&ref=01012052&ref=30257523&dob=01062017&dob=0101970
results in only the following being logged:
[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
Also I know I shouldn't be using r:err but it is down logging level of the apache installation and I cannot change it so err ensured I got the logs.
apache2 has the following modules loaded:
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)