HTTP: stored matched action in nxt_http_request_t.
No functional changes.
This commit is contained in:
@@ -173,6 +173,7 @@ struct nxt_http_request_s {
|
|||||||
nxt_tstr_query_t *tstr_query;
|
nxt_tstr_query_t *tstr_query;
|
||||||
nxt_tstr_cache_t tstr_cache;
|
nxt_tstr_cache_t tstr_cache;
|
||||||
|
|
||||||
|
nxt_http_action_t *action;
|
||||||
void *req_rpc_data;
|
void *req_rpc_data;
|
||||||
|
|
||||||
#if (NXT_HAVE_REGEX)
|
#if (NXT_HAVE_REGEX)
|
||||||
@@ -382,8 +383,7 @@ nxt_int_t nxt_upstreams_joint_create(nxt_router_temp_conf_t *tmcf,
|
|||||||
|
|
||||||
nxt_int_t nxt_http_rewrite_init(nxt_router_conf_t *rtcf,
|
nxt_int_t nxt_http_rewrite_init(nxt_router_conf_t *rtcf,
|
||||||
nxt_http_action_t *action, nxt_http_action_conf_t *acf);
|
nxt_http_action_t *action, nxt_http_action_conf_t *acf);
|
||||||
nxt_int_t nxt_http_rewrite(nxt_task_t *task, nxt_http_request_t *r,
|
nxt_int_t nxt_http_rewrite(nxt_task_t *task, nxt_http_request_t *r);
|
||||||
nxt_http_action_t *action);
|
|
||||||
|
|
||||||
nxt_int_t nxt_http_return_init(nxt_router_conf_t *rtcf,
|
nxt_int_t nxt_http_return_init(nxt_router_conf_t *rtcf,
|
||||||
nxt_http_action_t *action, nxt_http_action_conf_t *acf);
|
nxt_http_action_t *action, nxt_http_action_conf_t *acf);
|
||||||
|
|||||||
@@ -560,11 +560,9 @@ nxt_http_request_action(nxt_task_t *task, nxt_http_request_t *r,
|
|||||||
if (nxt_fast_path(action != NULL)) {
|
if (nxt_fast_path(action != NULL)) {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (action->rewrite != NULL) {
|
ret = nxt_http_rewrite(task, r);
|
||||||
ret = nxt_http_rewrite(task, r, action);
|
if (nxt_slow_path(ret != NXT_OK)) {
|
||||||
if (nxt_slow_path(ret != NXT_OK)) {
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
action = action->handler(task, r, action);
|
action = action->handler(task, r, action);
|
||||||
|
|||||||
@@ -26,15 +26,21 @@ nxt_http_rewrite_init(nxt_router_conf_t *rtcf, nxt_http_action_t *action,
|
|||||||
|
|
||||||
|
|
||||||
nxt_int_t
|
nxt_int_t
|
||||||
nxt_http_rewrite(nxt_task_t *task, nxt_http_request_t *r,
|
nxt_http_rewrite(nxt_task_t *task, nxt_http_request_t *r)
|
||||||
nxt_http_action_t *action)
|
|
||||||
{
|
{
|
||||||
u_char *p;
|
u_char *p;
|
||||||
nxt_int_t ret;
|
nxt_int_t ret;
|
||||||
nxt_str_t str, encoded_path, target;
|
nxt_str_t str, encoded_path, target;
|
||||||
nxt_router_conf_t *rtcf;
|
nxt_router_conf_t *rtcf;
|
||||||
|
nxt_http_action_t *action;
|
||||||
nxt_http_request_parse_t rp;
|
nxt_http_request_parse_t rp;
|
||||||
|
|
||||||
|
action = r->action;
|
||||||
|
|
||||||
|
if (action == NULL || action->rewrite == NULL) {
|
||||||
|
return NXT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (nxt_tstr_is_const(action->rewrite)) {
|
if (nxt_tstr_is_const(action->rewrite)) {
|
||||||
nxt_tstr_str(action->rewrite, &str);
|
nxt_tstr_str(action->rewrite, &str);
|
||||||
|
|
||||||
|
|||||||
@@ -1573,6 +1573,11 @@ nxt_http_route_handler(nxt_task_t *task, nxt_http_request_t *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action != NULL) {
|
if (action != NULL) {
|
||||||
|
|
||||||
|
if (action != NXT_HTTP_ACTION_ERROR) {
|
||||||
|
r->action = action;
|
||||||
|
}
|
||||||
|
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -696,6 +696,8 @@ nxt_http_static_next(nxt_task_t *task, nxt_http_request_t *r,
|
|||||||
if (nxt_slow_path(r->log_route)) {
|
if (nxt_slow_path(r->log_route)) {
|
||||||
nxt_log(task, NXT_LOG_NOTICE, "\"fallback\" taken");
|
nxt_log(task, NXT_LOG_NOTICE, "\"fallback\" taken");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r->action = action->fallback;
|
||||||
nxt_http_request_action(task, r, action->fallback);
|
nxt_http_request_action(task, r, action->fallback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user