1
0
mirror of https://github.com/graygnuorg/pound.git synced 2026-10-28 11:35:07 +03:00
Files
pound/tests/chgvis.at
Sergey Poznyakoff 3cd8178c85 Improve request matching and implement request modification directives.
Implement request accessors. Test rewrite rules.

Keep a cyclic queue of submatches

Up to 8 recent matches can be referenced in arguments to request
modification directives.  The notation $N refers to the Nth sub-
expression of the most recent match.  The notation $N(M) refers
to the Nth subexpression of the Mth recent match (match indexes
are 0-based).  For compatibility with versions 4.4-4.5, %N is
taken to mean $N(1).

* src/http.c: Rewrite http_request support.
(match_cond): Move from svc.c. Add support for new condition types.
(rewrite_apply): New function.
(send_to_backend): Call rewrite_apply.
(expand_string_to_buffer,expand_string): New function.
(expand_url): Rewrite using expand_string_to_buffer.
(urldecode,urlencode): New functions.
(submatch_reset,submatch_queue_init)
(submatch_queue_get,submatch_queue_push)
(submatch_queue_free): New functions.
(expand_string_to_buffer): Rewrite using submatch_queue.  All
uses changed.
Implement request accessors.
Fix dead loop occurring when invalid percent sequence is encountered.
(match_cond): Change signature. Use submatch_queue_push to
get new submatch slot each time it is needed.
(rewrite_rule_check, rewrite_op_apply): Change signature. All uses
changed.
(expand_string_to_buffer): Support ${N} notation
along with $N. Count accessor expansions in the return value.
(send_to_backend): Apply listener's rewrite rules.
(http_request_rebuild): Replace with three functions, invoked when
needed: http_request_rebuild_line, http_request_rebuild_url, and
http_request_rebuild_query.
(http_header_list_filter): Bugfix: revert condition.
* src/pound.c (pound_http_enqueue): Add explanatory comment.
(pound_http_destroy): Call submatch_queue_free.
* src/pound.h (query_param,QUERY_HEAD): New aggregate types.
(http_request): New fields: path, query_raw, query, frag_raw,
frag, orig_request_line, flags.
(be_redirect): Rename append_uri to has_uri, to avoid confusion.
(COND_PATH,COND_QUERY,COND_QUERY_PARAM,COND_FRAG): New cond types.
(query_param_match): New aggregate type.
(SERVICE_COND): New union member: qp.
(REWRITE_OP,REWRITE_OP_HEAD)
(REWRITE_RULE_HEAD,REWRITE_RULE): New aggregate types.
(SERVICE): New field: rewrite.
(struct submatch): Subject is allocated, so remove the const
qualifier.
(get_service): Simplify signature.
(match_cond): New proto.
(SMQ_SIZE): New constant.
(submatch_queue): New struct.
(submatch_free): Remove proto.
(submatch_queue_free): New proto.
(POUND_HTTP): Remove field sm.
New field smq.
(get_service): Change signature.
(LISTENER): Remove head_off and add_header. New field: rewrite.
(http_request): Replace "flags" field with "split".
HRF_* constants removed as well.
* src/svc.c (match_service,get_service): Change signature.
* src/config.c (input): Remove field: ready. New fields: putback
and putback_index.
(input_gettkn, input_putback): Rewrite putback handling.
New block statement: Rewrite ... [Else ...] End
New statements: Path, Query, QueryParam, Fragment,
SetHeader, DeleteHeader, SetURL, SetPath, SetQuery,
SetQueryParam, SetFragment.
Remove "AND" and "OR" block statements (these were undocumented
 shortcuts for "Match AND" and "Match OR").
(parse_header_remove): New function. Handles
HeaderRemove (HeadRemove) keywords.
HeaderAdd, and AddHeader are handled as synonims of SetHeader.
LISTENERs rewrite field.
Fix formation of regular expression for matchers.
Allow for "set" statements without enclosing Rewrite block.

* tests/Makefile.am: Add new tests.
* tests/testsuite.at: Likewise.
* tests/chgvis.at: New file.
* tests/reqacc.at: New file.
* tests/rwchain.at: New file.
* tests/set.at: New file.
* tests/headrem.at: Rewrite test to catch eventual bugs in
http_header_list_filter.

* NEWS: Document changes.
* doc/pound.8: Likewise.
2023-02-17 21:27:44 +02:00

41 lines
987 B
Plaintext

# This file is part of pound testsuite. -*- autotest -*-
# Copyright (C) 2023 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([Visibility of changes])
AT_KEYWORDS([rewrite chgvis accessor])
PT_CHECK([ListenHTTP
Service
Rewrite
SetURL "/other"
SetPath ["/echo%[path]"]
End
Backend
Address
Port
End
End
End
],
[GET /one
end
200
x-orig-uri: /echo/other
end
])
AT_CLEANUP