Ticket #1307 (new enhancement)
Impossible to loop through the lighty.request or lighty.env fields
| Reported by: | anonymous | Owned by: | jan |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.4.20 |
| Component: | mod_magnet | Version: | 1.4.16 |
| Severity: | normal | Keywords: | |
| Cc: | Blocked By: | ||
| Need User Feedback: | no | Blocking: |
Description
In order to log all request headers or matching their names against a given pattern (i.e. *proxy*), it should be possible to traverse the lighty.request and lighty.env tables.
The following debug code however only processes what seems to be empty tables. Requesting a field directly, returns the value as exptected (see last line of output):
print('--------- BEGIN OF DUMP -----------')
-- loop through main "lighty" table and output its
-- type and contents (including subtables)
for key,val in pairs(lighty) do
if type(val) == 'table' then
print('TABLE: ' .. key .. '(Length: ' .. #val .. ')')
-- loop through sub-table of "lighty"
for key2,val2 in pairs(val) do
if val2 == nil then
print(' - ' .. key2 .. ': (NULL)')
else
print(' - ' .. key2 .. ': ' .. val2)
end
end
-- end of subtable
elseif type(val) == 'string' then
if val == nil then
print ('STRING: ' .. key .. ': (NULL)')
else
print ('STRING: ' .. key .. ': ' .. val)
end
else
print ('ISTYPE: ' .. key .. ': ' .. type(val))
end
end
print('--------- END OF DUMP -------------')
print(lighty.request['User-Agent'])
Request:
GET / HTTP/1.1 Host: localhost User-Agent: This is my User-Agent Connection: close
Output:
--------- BEGIN OF DUMP ----------- ISTYPE: RESTART_REQUEST: number TABLE: header(Length: 0) ISTYPE: stat: function TABLE: request(Length: 0) TABLE: env(Length: 0) TABLE: content(Length: 0) TABLE: status(Length: 0) --------- END OF DUMP ------------- This is my User-Agent
Tested on 1.4.16 (Linux x86_64).
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

