summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2024-04-30 14:45:18 +0800
committerZhidao HONG <z.hong@f5.com>2024-05-09 09:51:34 +0800
commit87077ec4ba9a59f3332c3758a3c39a5c149025e5 (patch)
treec95be76a27c366da8b166add815ae3f5386e1376 /src
parent05a822947444a462bd21bf48ecb8c7328e4e156b (diff)
downloadunit-87077ec4ba9a59f3332c3758a3c39a5c149025e5.tar.gz
unit-87077ec4ba9a59f3332c3758a3c39a5c149025e5.tar.bz2
http: Ensure REQUEST_URI immutability
Previously, the REQUEST_URI within Unit could be modified, for example, during uri rewriting. We decide to make $request_uri immutable and pass constant REQUEST_URI to applications. Based on the new requirement, we remove `r->target` rewriting in the rewrite module. Closes: https://github.com/nginx/unit/issues/916 Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Signed-off-by: Zhidao HONG <z.hong@f5.com>
Diffstat (limited to 'src')
-rw-r--r--src/nxt_http_rewrite.c29
1 files changed, 2 insertions, 27 deletions
diff --git a/src/nxt_http_rewrite.c b/src/nxt_http_rewrite.c
index ff465ecc..661200ef 100644
--- a/src/nxt_http_rewrite.c
+++ b/src/nxt_http_rewrite.c
@@ -28,9 +28,8 @@ nxt_http_rewrite_init(nxt_router_conf_t *rtcf, nxt_http_action_t *action,
nxt_int_t
nxt_http_rewrite(nxt_task_t *task, nxt_http_request_t *r)
{
- u_char *p;
nxt_int_t ret;
- nxt_str_t str, encoded_path, target;
+ nxt_str_t str;
nxt_router_conf_t *rtcf;
nxt_http_action_t *action;
nxt_http_request_parse_t rp;
@@ -72,30 +71,6 @@ nxt_http_rewrite(nxt_task_t *task, nxt_http_request_t *r)
return NXT_ERROR;
}
- p = (rp.args.length > 0) ? rp.args.start - 1 : rp.target_end;
-
- encoded_path.start = rp.target_start;
- encoded_path.length = p - encoded_path.start;
-
- if (r->args->length == 0) {
- r->target = encoded_path;
-
- } else {
- target.length = encoded_path.length + 1 + r->args->length;
-
- target.start = nxt_mp_alloc(r->mem_pool, target.length);
- if (target.start == NULL) {
- return NXT_ERROR;
- }
-
- p = nxt_cpymem(target.start, encoded_path.start, encoded_path.length);
- *p++ = '?';
- nxt_memcpy(p, r->args->start, r->args->length);
-
- r->target = target;
- r->args->start = p;
- }
-
r->path = nxt_mp_alloc(r->mem_pool, sizeof(nxt_str_t));
if (nxt_slow_path(r->path == NULL)) {
return NXT_ERROR;
@@ -107,7 +82,7 @@ nxt_http_rewrite(nxt_task_t *task, nxt_http_request_t *r)
r->quoted_target = rp.quoted_target;
if (nxt_slow_path(r->log_route)) {
- nxt_log(task, NXT_LOG_NOTICE, "URI rewritten to \"%V\"", &r->target);
+ nxt_log(task, NXT_LOG_NOTICE, "URI rewritten to \"%V\"", r->path);
}
return NXT_OK;