summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_controller.c
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2019-05-30 17:44:29 +0300
committerAndrei Belov <defan@nginx.com>2019-05-30 17:44:29 +0300
commit4921df052be8437d912f3c60faa9a667890e4498 (patch)
tree3678c551f148a0d177721597de978c090237f205 /src/nxt_controller.c
parent3b7a7ff2aa5840d4238584410ee1ebc6860fb9c5 (diff)
parent7da320a93af07765e79c929287704936c431f3cd (diff)
downloadunit-4921df052be8437d912f3c60faa9a667890e4498.tar.gz
unit-4921df052be8437d912f3c60faa9a667890e4498.tar.bz2
Merged with the default branch.1.9.0-1
Diffstat (limited to 'src/nxt_controller.c')
-rw-r--r--src/nxt_controller.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/nxt_controller.c b/src/nxt_controller.c
index 29838bd9..49afbe46 100644
--- a/src/nxt_controller.c
+++ b/src/nxt_controller.c
@@ -184,6 +184,7 @@ nxt_controller_start(nxt_task_t *task, void *data)
vldt.pool = nxt_mp_create(1024, 128, 256, 32);
if (nxt_slow_path(vldt.pool == NULL)) {
+ nxt_mp_destroy(mp);
return NXT_ERROR;
}
@@ -929,6 +930,7 @@ nxt_controller_process_config(nxt_task_t *task, nxt_controller_request_t *req,
nxt_mp_t *mp;
nxt_int_t rc;
nxt_conn_t *c;
+ nxt_bool_t post;
nxt_buf_mem_t *mbuf;
nxt_conf_op_t *ops;
nxt_conf_value_t *value;
@@ -957,7 +959,18 @@ nxt_controller_process_config(nxt_task_t *task, nxt_controller_request_t *req,
return;
}
- if (nxt_str_eq(&req->parser.method, "PUT", 3)) {
+ if (nxt_str_eq(&req->parser.method, "POST", 4)) {
+ if (path->length == 1) {
+ goto not_allowed;
+ }
+
+ post = 1;
+
+ } else {
+ post = 0;
+ }
+
+ if (post || nxt_str_eq(&req->parser.method, "PUT", 3)) {
if (!nxt_queue_is_empty(&nxt_controller_waiting_requests)) {
nxt_queue_insert_tail(&nxt_controller_waiting_requests, &req->link);
@@ -999,15 +1012,20 @@ nxt_controller_process_config(nxt_task_t *task, nxt_controller_request_t *req,
if (path->length != 1) {
rc = nxt_conf_op_compile(c->mem_pool, &ops,
nxt_controller_conf.root,
- path, value);
+ path, value, post);
- if (rc != NXT_OK) {
+ if (rc != NXT_CONF_OP_OK) {
nxt_mp_destroy(mp);
- if (rc == NXT_DECLINED) {
+ switch (rc) {
+ case NXT_CONF_OP_NOT_FOUND:
goto not_found;
+
+ case NXT_CONF_OP_NOT_ALLOWED:
+ goto not_allowed;
}
+ /* rc == NXT_CONF_OP_ERROR */
goto alloc_fail;
}
@@ -1079,13 +1097,14 @@ nxt_controller_process_config(nxt_task_t *task, nxt_controller_request_t *req,
} else {
rc = nxt_conf_op_compile(c->mem_pool, &ops,
nxt_controller_conf.root,
- path, NULL);
+ path, NULL, 0);
if (rc != NXT_OK) {
- if (rc == NXT_DECLINED) {
+ if (rc == NXT_CONF_OP_NOT_FOUND) {
goto not_found;
}
+ /* rc == NXT_CONF_OP_ERROR */
goto alloc_fail;
}
@@ -1144,8 +1163,10 @@ nxt_controller_process_config(nxt_task_t *task, nxt_controller_request_t *req,
return;
}
+not_allowed:
+
resp.status = 405;
- resp.title = (u_char *) "Invalid method.";
+ resp.title = (u_char *) "Method isn't allowed.";
resp.offset = -1;
nxt_controller_response(task, req, &resp);