mirror of
https://github.com/graygnuorg/pound.git
synced 2026-10-25 10:19:36 +03:00
This extends the functionality added in 3758b19774, by allowing to
select the service to send the request to.
* src/http.c (capture_start, capture_end): Base logic on the
value phttp->capturing.
(backend_response): Close backend if the conn_closed flag is set.
(regular_response): Rework logic to move resending loop to the
caller.
(http_process_request): Move resending loop here.
* src/pndlua.c: New http field: service.
Fields available for reading: service.index, service.name, service.locus.
Fields available for writing: service.index, service.name. Setting these
selects another service (if non-nil), or resets it so that pound runs the
regular service selection logic afterwards.
* src/pound.h (resend_mode, capture_state): New data types.
(POUND_HTTP): Change type of the capturing field.
[ENABLE_LUA]: Change type of the resend field. New fields: resend_svc,
resend_count.
(phttp_lua_stash_reset): Reset new fields.
(phttp_resend_service,phttp_resend_next): New functions.
* tests/lua-resend-loop.at: New test.
* tests/lua-resend-same.at: New test.
* test/lua-resend-service.at: New test.
* test/lua-resend-nulsvc.at: New test.
* tests/Makefile.am: Add new tests.
* tests/testsuite.at: Likewise.
* tests/poundharness.pl: New backend etrypoint: /bauth (basic auth).
54 lines
1.2 KiB
Plaintext
54 lines
1.2 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([Resend to the same backend])
|
|
AT_KEYWORDS([cond lua lua-resend lua-resend-same])
|
|
|
|
AT_SKIP_IF([test "$LUA_AVAILABLE" != 1])
|
|
AT_DATA([auth.lua],
|
|
[function bauth()
|
|
if http.resp.code == 401 then
|
|
pound.log(pound.ERR, "Inject")
|
|
http.req.headers.authorization = "Basic Z3JheTpndWVzc01l"
|
|
http.resend = true
|
|
end
|
|
end
|
|
])
|
|
AT_DATA([userlist],
|
|
[gray:guessMe
|
|
])
|
|
|
|
PT_CHECK([Lua
|
|
Load "auth.lua"
|
|
End
|
|
ListenHTTP
|
|
Service
|
|
Rewrite response
|
|
LuaModify "bauth"
|
|
End
|
|
Backend
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /bauth/
|
|
end
|
|
|
|
200
|
|
end
|
|
])
|
|
|
|
AT_CLEANUP
|