1
0
mirror of https://github.com/graygnuorg/pound.git synced 2026-10-23 22:28:53 +03:00
Files
pound/tests/lua-const.at
Sergey Poznyakoff c452303b53 Implement configuration constants.
* src/cctype.c (c_memrspn, c_memrcspn): Return length of the matching
segment.
(c_trimrws): Take this change into account.
* src/cfgparser.c (kwn_to_tok): New function.
(filename_resolve): Bugfix: remove unneeded call to workdir_unref.
(slurp): New function.
(cfg_assign_string_from_file): Rewrite using slurp.
* src/cfgparser.h (STRING): New member: len.
(string_alloc): Initialize len.
(string_len): New function.
(slurp, kwn_to_tok): New protos.
* src/config.c (gettok_option): Return pointer to the struct
config_option found in the memory location pointed to by opt.
All uses changed.
(get_file_option): Change semantics of the third argument: it is
a bitmap of allowed option codes. Set *filename to a malloc'ed
copy of the filename found.
All uses changed.
(pound_http_get_strconst): New function.
(service_parsetab, http_common)
(top_level_parsetab): New keyword: Constant.
* src/http.c: New accessor: const.
* src/pndlua.c: New method of http: const.
* src/pound-mode.el: Recognize new keywords.
* src/pound.h (SERVICE, LISTENER): New field: sctab.
(pound_http_get_strconst): New extern.

* tests/const.at: New test.
* tests/lua-const.at: New test.
* tests/Makefile.am: Add new tests.
* tests/testsuite.at: Likewise.

* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/pound.texi: Likewise.
2026-05-07 22:58:59 +03:00

48 lines
1.1 KiB
Plaintext

# This file is part of pound testsuite. -*- autotest -*-
# Copyright (C) 2026 Sergey Poznyakoff
#
# Pound is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Pound is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pound. If not, see <http://www.gnu.org/licenses/>.
AT_SETUP([Access to constants])
AT_KEYWORDS([lua lua-mod lua-const])
AT_SKIP_IF([test "$LUA_AVAILABLE" != 1])
AT_DATA([mod.lua],
[[function x_const()
http.resp.headers = {
['X-Const'] = http:const("a")
}
end
]])
PT_CHECK([Lua
Load "mod.lua"
End
ListenHTTP
Constant "a" "some text"
Rewrite response
LuaModify "x_const"
End
Service
Backend
End
End
End
],
[GET /echo/file
end
200
X-Const: some text
end
])
AT_CLEANUP