diff options
author | Oisin Canty <o.canty@f5.com> | 2021-05-26 16:48:11 +0000 |
---|---|---|
committer | Oisin Canty <o.canty@f5.com> | 2021-05-26 16:48:11 +0000 |
commit | d67a0c871157454d591fa1d2a8b2d831b32e4040 (patch) | |
tree | 310bb0c560551f2f6d3409f651bdb1d17ecc63b6 /src/nxt_http_static.c | |
parent | 81e31872e3d05c912551dbf1382e3c78f4f65f4b (diff) | |
download | unit-d67a0c871157454d591fa1d2a8b2d831b32e4040.tar.gz unit-d67a0c871157454d591fa1d2a8b2d831b32e4040.tar.bz2 |
Static: handled unknown MIME types when MIME-filtering active.
Diffstat (limited to 'src/nxt_http_static.c')
-rw-r--r-- | src/nxt_http_static.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/nxt_http_static.c b/src/nxt_http_static.c index 08f451b6..c8b73fac 100644 --- a/src/nxt_http_static.c +++ b/src/nxt_http_static.c @@ -84,28 +84,22 @@ nxt_http_static_handler(nxt_task_t *task, nxt_http_request_t *r, mtype = nxt_http_static_mtypes_hash_find(&rtcf->mtypes_hash, &extension); - if (mtype != NULL) { - ret = nxt_http_route_test_rule(r, action->u.share.types, - mtype->start, mtype->length); - if (ret == 1) { - goto mime_ok; - } + ret = nxt_http_route_test_rule(r, action->u.share.types, + mtype->start, mtype->length); + if (nxt_slow_path(ret == NXT_ERROR)) { + goto fail; + } - if (nxt_slow_path(ret == NXT_ERROR)) { - goto fail; + if (ret == 0) { + if (action->u.share.fallback != NULL) { + return action->u.share.fallback; } - } - if (action->u.share.fallback != NULL) { - return action->u.share.fallback; + nxt_http_request_error(task, r, NXT_HTTP_FORBIDDEN); + return NULL; } - - nxt_http_request_error(task, r, NXT_HTTP_FORBIDDEN); - return NULL; } -mime_ok: - length = action->name.length + r->path->length + index.length; fname = nxt_mp_nget(r->mem_pool, length + 1); @@ -298,7 +292,7 @@ mime_ok: &extension); } - if (mtype != NULL) { + if (mtype->length != 0) { field = nxt_list_zero_add(r->resp.fields); if (nxt_slow_path(field == NULL)) { goto fail; @@ -711,6 +705,8 @@ nxt_http_static_mtypes_hash_find(nxt_lvlhsh_t *hash, nxt_str_t *extension) nxt_lvlhsh_query_t lhq; nxt_http_static_mtype_t *mtype; + static nxt_str_t empty = nxt_string(""); + lhq.key = *extension; lhq.key_hash = nxt_djb_hash_lowcase(lhq.key.start, lhq.key.length); lhq.proto = &nxt_http_static_mtypes_hash_proto; @@ -720,7 +716,7 @@ nxt_http_static_mtypes_hash_find(nxt_lvlhsh_t *hash, nxt_str_t *extension) return mtype->type; } - return NULL; + return ∅ } |