Changeset a4484cbe427852e7f5bed1cfb04af21d20728dac

Show
Ignore:
Timestamp:
09/16/09 18:41:55 (5 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
  • src/noit_check_rest.c

    r2082a78 ra4484cb  
    6666  noit_check_t *check; 
    6767  char xpath[1024], *uuid_conf, *module, *value; 
    68   int rv, cnt
     68  int rv, cnt, error_code = 500
    6969  noit_hash_iter iter = NOIT_HASH_ITER_ZERO; 
    7070  const char *k; 
     
    131131  xmlAddChild(root, attr); 
    132132 
     133  SHOW_ATTR(attr,node,uuid); 
     134 
    133135  /* Name is odd, it falls back transparently to module */ 
    134136  if(!INHERIT(node, module, tmp, module)) module = NULL; 
     
    220222 
    221223 error: 
    222   noit_http_response_server_error(ctx, "text/html"); 
     224  noit_http_response_standard(ctx, error_code, "ERROR", "text/html"); 
    223225  noit_http_response_end(ctx); 
    224226  goto cleanup; 
     
    392394  const char *error; 
    393395  char xpath[1024], *uuid_conf; 
    394   int rv, cnt
     396  int rv, cnt, error_code = 500
    395397  noit_boolean exists = noit_false; 
    396398 
     
    410412  if(!pobj || pobj->type != XPATH_NODESET || 
    411413     xmlXPathNodeSetIsEmpty(pobj->nodesetval)) { 
    412     if(exists) FAIL("uuid not yours"); 
     414    if(exists) { error_code = 403; FAIL("uuid not yours"); } 
    413415    goto not_found; 
    414416  } 
     
    437439 
    438440 error: 
    439   noit_http_response_server_error(ctx, "text/html"); 
     441  noit_http_response_standard(ctx, error_code, "ERROR", "text/html"); 
    440442  noit_http_response_end(ctx); 
    441443  goto cleanup; 
     
    457459  noit_check_t *check; 
    458460  char xpath[1024], *uuid_conf; 
    459   int rv, cnt
     461  int rv, cnt, error_code = 500
    460462  const char *error = "internal error"; 
    461463  noit_boolean exists = noit_false; 
     
    505507  if(!pobj || pobj->type != XPATH_NODESET || 
    506508     xmlXPathNodeSetIsEmpty(pobj->nodesetval)) { 
    507     if(exists) FAIL("uuid not yours"); 
     509    if(exists) { error_code = 403; FAIL("uuid not yours"); } 
    508510    else { 
    509511      char *target = NULL, *name = NULL, *module = NULL; 
     
    585587 
    586588 error: 
    587   noit_http_response_server_error(ctx, "text/xml"); 
     589  noit_http_response_standard(ctx, error_code, "ERROR", "text/html"); 
    588590  doc = xmlNewDoc((xmlChar *)"1.0"); 
    589591  root = xmlNewDocNode(doc, NULL, (xmlChar *)"error", NULL);