Changeset a4484cbe427852e7f5bed1cfb04af21d20728dac
- Timestamp:
- 09/16/09 18:41:55
(4 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1253126515 +0000
- git-parent:
[2082a78beb17f79bf82cda8b6f185dab85593bbe]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1253126515 +0000
- Message:
allow custom error codes, refs #171
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2082a78 |
ra4484cb |
|
| 66 | 66 | noit_check_t *check; |
|---|
| 67 | 67 | char xpath[1024], *uuid_conf, *module, *value; |
|---|
| 68 | | int rv, cnt; |
|---|
| | 68 | int rv, cnt, error_code = 500; |
|---|
| 69 | 69 | noit_hash_iter iter = NOIT_HASH_ITER_ZERO; |
|---|
| 70 | 70 | const char *k; |
|---|
| … | … | |
| 131 | 131 | xmlAddChild(root, attr); |
|---|
| 132 | 132 | |
|---|
| | 133 | SHOW_ATTR(attr,node,uuid); |
|---|
| | 134 | |
|---|
| 133 | 135 | /* Name is odd, it falls back transparently to module */ |
|---|
| 134 | 136 | if(!INHERIT(node, module, tmp, module)) module = NULL; |
|---|
| … | … | |
| 220 | 222 | |
|---|
| 221 | 223 | error: |
|---|
| 222 | | noit_http_response_server_error(ctx, "text/html"); |
|---|
| | 224 | noit_http_response_standard(ctx, error_code, "ERROR", "text/html"); |
|---|
| 223 | 225 | noit_http_response_end(ctx); |
|---|
| 224 | 226 | goto cleanup; |
|---|
| … | … | |
| 392 | 394 | const char *error; |
|---|
| 393 | 395 | char xpath[1024], *uuid_conf; |
|---|
| 394 | | int rv, cnt; |
|---|
| | 396 | int rv, cnt, error_code = 500; |
|---|
| 395 | 397 | noit_boolean exists = noit_false; |
|---|
| 396 | 398 | |
|---|
| … | … | |
| 410 | 412 | if(!pobj || pobj->type != XPATH_NODESET || |
|---|
| 411 | 413 | xmlXPathNodeSetIsEmpty(pobj->nodesetval)) { |
|---|
| 412 | | if(exists) FAIL("uuid not yours"); |
|---|
| | 414 | if(exists) { error_code = 403; FAIL("uuid not yours"); } |
|---|
| 413 | 415 | goto not_found; |
|---|
| 414 | 416 | } |
|---|
| … | … | |
| 437 | 439 | |
|---|
| 438 | 440 | error: |
|---|
| 439 | | noit_http_response_server_error(ctx, "text/html"); |
|---|
| | 441 | noit_http_response_standard(ctx, error_code, "ERROR", "text/html"); |
|---|
| 440 | 442 | noit_http_response_end(ctx); |
|---|
| 441 | 443 | goto cleanup; |
|---|
| … | … | |
| 457 | 459 | noit_check_t *check; |
|---|
| 458 | 460 | char xpath[1024], *uuid_conf; |
|---|
| 459 | | int rv, cnt; |
|---|
| | 461 | int rv, cnt, error_code = 500; |
|---|
| 460 | 462 | const char *error = "internal error"; |
|---|
| 461 | 463 | noit_boolean exists = noit_false; |
|---|
| … | … | |
| 505 | 507 | if(!pobj || pobj->type != XPATH_NODESET || |
|---|
| 506 | 508 | xmlXPathNodeSetIsEmpty(pobj->nodesetval)) { |
|---|
| 507 | | if(exists) FAIL("uuid not yours"); |
|---|
| | 509 | if(exists) { error_code = 403; FAIL("uuid not yours"); } |
|---|
| 508 | 510 | else { |
|---|
| 509 | 511 | char *target = NULL, *name = NULL, *module = NULL; |
|---|
| … | … | |
| 585 | 587 | |
|---|
| 586 | 588 | error: |
|---|
| 587 | | noit_http_response_server_error(ctx, "text/xml"); |
|---|
| | 589 | noit_http_response_standard(ctx, error_code, "ERROR", "text/html"); |
|---|
| 588 | 590 | doc = xmlNewDoc((xmlChar *)"1.0"); |
|---|
| 589 | 591 | root = xmlNewDocNode(doc, NULL, (xmlChar *)"error", NULL); |
|---|