summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nxt_http_static.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/nxt_http_static.c b/src/nxt_http_static.c
index ee25015e..67591595 100644
--- a/src/nxt_http_static.c
+++ b/src/nxt_http_static.c
@@ -47,8 +47,8 @@ static nxt_http_action_t *nxt_http_static(nxt_task_t *task,
nxt_http_request_t *r, nxt_http_action_t *action);
static void nxt_http_static_iterate(nxt_task_t *task, nxt_http_request_t *r,
nxt_http_static_ctx_t *ctx);
-static void nxt_http_static_send_ready(nxt_task_t *task, void *obj, void *data);
-static void nxt_http_static_send_error(nxt_task_t *task, void *obj, void *data);
+static void nxt_http_static_send(nxt_task_t *task, nxt_http_request_t *r,
+ nxt_http_static_ctx_t *ctx);
static void nxt_http_static_next(nxt_task_t *task, nxt_http_request_t *r,
nxt_http_static_ctx_t *ctx, nxt_http_status_t status);
#if (NXT_HAVE_OPENAT2)
@@ -271,35 +271,44 @@ nxt_http_static_iterate(nxt_task_t *task, nxt_http_request_t *r,
}
#endif
- nxt_http_static_send_ready(task, r, ctx);
-
} else {
rtcf = r->conf->socket_conf->router_conf;
ret = nxt_tstr_query_init(&r->tstr_query, rtcf->tstr_state,
&r->tstr_cache, r, r->mem_pool);
if (nxt_slow_path(ret != NXT_OK)) {
- nxt_http_request_error(task, r, NXT_HTTP_INTERNAL_SERVER_ERROR);
- return;
+ goto fail;
}
- nxt_tstr_query(task, r->tstr_query, share->tstr, &ctx->share);
+ ret = nxt_tstr_query(task, r->tstr_query, share->tstr, &ctx->share);
+ if (nxt_slow_path(ret != NXT_OK)) {
+ goto fail;
+ }
#if (NXT_HAVE_OPENAT2)
if (conf->chroot != NULL && ctx->share_idx == 0) {
- nxt_tstr_query(task, r->tstr_query, conf->chroot, &ctx->chroot);
+ ret = nxt_tstr_query(task, r->tstr_query, conf->chroot,
+ &ctx->chroot);
+ if (nxt_slow_path(ret != NXT_OK)) {
+ goto fail;
+ }
}
#endif
+ }
+
+ nxt_http_static_send(task, r, ctx);
+
+ return;
+
+fail:
- nxt_tstr_query_resolve(task, r->tstr_query, ctx,
- nxt_http_static_send_ready,
- nxt_http_static_send_error);
- }
+ nxt_http_request_error(task, r, NXT_HTTP_INTERNAL_SERVER_ERROR);
}
static void
-nxt_http_static_send_ready(nxt_task_t *task, void *obj, void *data)
+nxt_http_static_send(nxt_task_t *task, nxt_http_request_t *r,
+ nxt_http_static_ctx_t *ctx)
{
size_t length, encode;
u_char *p, *fname;
@@ -314,13 +323,9 @@ nxt_http_static_send_ready(nxt_task_t *task, void *obj, void *data)
nxt_http_status_t status;
nxt_router_conf_t *rtcf;
nxt_http_action_t *action;
- nxt_http_request_t *r;
nxt_work_handler_t body_handler;
- nxt_http_static_ctx_t *ctx;
nxt_http_static_conf_t *conf;
- r = obj;
- ctx = data;
action = ctx->action;
conf = action->u.conf;
rtcf = r->conf->socket_conf->router_conf;
@@ -663,17 +668,6 @@ fail:
static void
-nxt_http_static_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 void
nxt_http_static_next(nxt_task_t *task, nxt_http_request_t *r,
nxt_http_static_ctx_t *ctx, nxt_http_status_t status)
{