summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2024-04-18 18:20:53 +0800
committerZhidao HONG <z.hong@f5.com>2024-08-20 09:17:23 +0800
commit76a255b27ec2351ce580baaf54d28ee4b59680ad (patch)
treec794ef81986411d2eab5d739ea3c967dcbb19d37 /src
parent2eecee7520558a8f72e98e839a77330712a946b4 (diff)
downloadunit-76a255b27ec2351ce580baaf54d28ee4b59680ad.tar.gz
unit-76a255b27ec2351ce580baaf54d28ee4b59680ad.tar.bz2
http: Refactor return action
Diffstat (limited to 'src')
-rw-r--r--src/nxt_http_return.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/src/nxt_http_return.c b/src/nxt_http_return.c
index b50e4ad0..a3551683 100644
--- a/src/nxt_http_return.c
+++ b/src/nxt_http_return.c
@@ -24,8 +24,8 @@ static nxt_http_action_t *nxt_http_return(nxt_task_t *task,
nxt_http_request_t *r, nxt_http_action_t *action);
static nxt_int_t nxt_http_return_encode(nxt_mp_t *mp, nxt_str_t *encoded,
const nxt_str_t *location);
-static void nxt_http_return_send_ready(nxt_task_t *task, void *obj, void *data);
-static void nxt_http_return_send_error(nxt_task_t *task, void *obj, void *data);
+static void nxt_http_return_send(nxt_task_t *task, nxt_http_request_t *r,
+ nxt_http_return_ctx_t *ctx);
static const nxt_http_request_state_t nxt_http_return_send_state;
@@ -120,8 +120,6 @@ nxt_http_return(nxt_task_t *task, nxt_http_request_t *r,
ctx->encoded = conf->encoded;
}
- nxt_http_return_send_ready(task, r, ctx);
-
} else {
rtcf = r->conf->socket_conf->router_conf;
@@ -131,13 +129,15 @@ nxt_http_return(nxt_task_t *task, nxt_http_request_t *r,
goto fail;
}
- nxt_tstr_query(task, r->tstr_query, conf->location, &ctx->location);
-
- nxt_tstr_query_resolve(task, r->tstr_query, ctx,
- nxt_http_return_send_ready,
- nxt_http_return_send_error);
+ ret = nxt_tstr_query(task, r->tstr_query, conf->location,
+ &ctx->location);
+ if (nxt_slow_path(ret != NXT_OK)) {
+ goto fail;
+ }
}
+ nxt_http_return_send(task, r, ctx);
+
return NULL;
fail:
@@ -174,15 +174,11 @@ nxt_http_return_encode(nxt_mp_t *mp, nxt_str_t *encoded,
static void
-nxt_http_return_send_ready(nxt_task_t *task, void *obj, void *data)
+nxt_http_return_send(nxt_task_t *task, nxt_http_request_t *r,
+ nxt_http_return_ctx_t *ctx)
{
- nxt_int_t ret;
- nxt_http_field_t *field;
- nxt_http_request_t *r;
- nxt_http_return_ctx_t *ctx;
-
- r = obj;
- ctx = data;
+ nxt_int_t ret;
+ nxt_http_field_t *field;
if (ctx != NULL) {
if (ctx->location.length > 0) {
@@ -216,17 +212,6 @@ fail:
}
-static void
-nxt_http_return_send_error(nxt_task_t *task, void *obj, void *data)
-{
- nxt_http_request_t *r;
-
- r = obj;
-
- nxt_http_request_error(task, r, NXT_HTTP_INTERNAL_SERVER_ERROR);
-}
-
-
static const nxt_http_request_state_t nxt_http_return_send_state
nxt_aligned(64) =
{