This commit is contained in:
willmafh 2025-07-16 20:11:35 +02:00 committed by GitHub
commit c9e706e2f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 0 deletions

View File

@ -1045,6 +1045,8 @@ ngx_http_core_find_config_phase(ngx_http_request_t *r,
ngx_memcpy(p, r->args.data, r->args.len); ngx_memcpy(p, r->args.data, r->args.len);
} }
r->request_auto_redirect = 1;
ngx_http_finalize_request(r, NGX_HTTP_MOVED_PERMANENTLY); ngx_http_finalize_request(r, NGX_HTTP_MOVED_PERMANENTLY);
return NGX_OK; return NGX_OK;
} }

View File

@ -545,6 +545,7 @@ struct ngx_http_request_s {
unsigned error_page:1; unsigned error_page:1;
unsigned filter_finalize:1; unsigned filter_finalize:1;
unsigned post_action:1; unsigned post_action:1;
unsigned request_auto_redirect:1;
unsigned request_complete:1; unsigned request_complete:1;
unsigned request_output:1; unsigned request_output:1;
unsigned header_sent:1; unsigned header_sent:1;

View File

@ -93,6 +93,8 @@ static ngx_int_t ngx_http_variable_body_bytes_sent(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data); ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_pipe(ngx_http_request_t *r, static ngx_int_t ngx_http_variable_pipe(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data); ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_request_auto_redirect(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_request_completion(ngx_http_request_t *r, static ngx_int_t ngx_http_variable_request_completion(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data); ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_request_body(ngx_http_request_t *r, static ngx_int_t ngx_http_variable_request_body(ngx_http_request_t *r,
@ -284,6 +286,10 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
{ ngx_string("pipe"), NULL, ngx_http_variable_pipe, { ngx_string("pipe"), NULL, ngx_http_variable_pipe,
0, 0, 0 }, 0, 0, 0 },
{ ngx_string("request_auto_redirect"), NULL,
ngx_http_variable_request_auto_redirect,
0, 0, 0 },
{ ngx_string("request_completion"), NULL, { ngx_string("request_completion"), NULL,
ngx_http_variable_request_completion, ngx_http_variable_request_completion,
0, 0, 0 }, 0, 0, 0 },
@ -2088,6 +2094,20 @@ ngx_http_variable_set_limit_rate(ngx_http_request_t *r,
} }
static ngx_int_t
ngx_http_variable_request_auto_redirect(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data)
{
if (r->request_auto_redirect) {
*v = ngx_http_variable_true_value;
return NGX_OK;
}
*v = ngx_http_variable_null_value;
return NGX_OK;
}
static ngx_int_t static ngx_int_t
ngx_http_variable_request_completion(ngx_http_request_t *r, ngx_http_variable_request_completion(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data) ngx_http_variable_value_t *v, uintptr_t data)