Show
Ignore:
Timestamp:
01/05/11 02:42:51 (7 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1294195371 +0000
git-parent:

[000581aaa029b35ddf2cf5f65f70c943df0cb405]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1294195371 +0000
Message:

updates... yay! for test suites... all passes, refs #334

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit_rest.c

    r90efcaa r6de024f  
    9696  struct rule_container *cont = NULL; 
    9797  struct rest_url_dispatcher *rule; 
    98   char *eoq, *eob; 
    99   eoq = strchr(restc->http_ctx->req.uri_str, '?'); 
     98  noit_http_request *req = noit_http_session_request(restc->http_ctx); 
     99  const char *uri_str; 
     100  const char *eoq, *eob; 
     101  uri_str = noit_http_request_uri_str(req); 
     102  eoq = strchr(uri_str, '?'); 
    100103  if(!eoq) 
    101     eoq = restc->http_ctx->req.uri_str + strlen(restc->http_ctx->req.uri_str); 
     104    eoq = uri_str + strlen(uri_str); 
    102105  eob = eoq - 1; 
    103106 
     
    105108  while(1) { 
    106109    void *vcont; 
    107     while(eob >= restc->http_ctx->req.uri_str && *eob != '/') eob--; 
    108     if(eob < restc->http_ctx->req.uri_str) break; /* off the front */ 
    109     if(noit_hash_retrieve(&dispatch_points, restc->http_ctx->req.uri_str, 
    110                           eob - restc->http_ctx->req.uri_str + 1, &vcont)) { 
     110    while(eob >= uri_str && *eob != '/') eob--; 
     111    if(eob < uri_str) break; /* off the front */ 
     112    if(noit_hash_retrieve(&dispatch_points, uri_str, 
     113                          eob - uri_str + 1, &vcont)) { 
    111114      cont = vcont; 
    112115      eob++; /* move past the determined base */ 
     
    119122    int ovector[30]; 
    120123    int cnt; 
    121     if(strcmp(rule->method, restc->http_ctx->req.method_str)) continue; 
     124    if(strcmp(rule->method, noit_http_request_method_str(req))) continue; 
    122125    if((cnt = pcre_exec(rule->expression, rule->extra, eob, eoq - eob, 0, 0, 
    123126                        ovector, sizeof(ovector)/sizeof(*ovector))) > 0) { 
     
    147150  struct noit_rest_acl *acl; 
    148151  struct noit_rest_acl_rule *rule; 
     152  noit_http_request *req = noit_http_session_request(restc->http_ctx); 
     153  const char *uri_str; 
    149154  int ovector[30]; 
    150155 
     156  uri_str = noit_http_request_uri_str(req); 
    151157  for(acl = global_rest_acls; acl; acl = acl->next) { 
    152158    if(acl->cn && pcre_exec(acl->cn, NULL, "", 0, 0, 0, 
    153159                            ovector, sizeof(ovector)/sizeof(*ovector)) <= 0) 
    154160      continue; 
    155     if(acl->url && pcre_exec(acl->url, NULL, restc->http_ctx->req.uri_str, 
    156                              strlen(restc->http_ctx->req.uri_str), 0, 0, 
     161    if(acl->url && pcre_exec(acl->url, NULL, uri_str, strlen(uri_str), 0, 0, 
    157162                             ovector, sizeof(ovector)/sizeof(*ovector)) <= 0) 
    158163      continue; 
     
    161166                               ovector, sizeof(ovector)/sizeof(*ovector)) <= 0) 
    162167        continue; 
    163       if(rule->url && pcre_exec(rule->url, NULL, restc->http_ctx->req.uri_str, 
    164                                 strlen(restc->http_ctx->req.uri_str), 0, 0, 
     168      if(rule->url && pcre_exec(rule->url, NULL, uri_str, strlen(uri_str), 0, 0, 
    165169                                ovector, sizeof(ovector)/sizeof(*ovector)) <= 0) 
    166170        continue; 
     
    176180  struct noit_rest_acl *acl; 
    177181  struct noit_rest_acl_rule *rule; 
     182  noit_http_request *req = noit_http_session_request(restc->http_ctx); 
     183  const char *uri_str; 
    178184  int ovector[30]; 
    179185 
     186  uri_str = noit_http_request_uri_str(req); 
    180187  if(!restc->remote_cn || !strlen(restc->remote_cn)) return noit_false; 
    181188  for(acl = global_rest_acls; acl; acl = acl->next) { 
     
    184191                            ovector, sizeof(ovector)/sizeof(*ovector)) <= 0) 
    185192      continue; 
    186     if(acl->url && pcre_exec(acl->url, NULL, restc->http_ctx->req.uri_str, 
    187                              strlen(restc->http_ctx->req.uri_str), 0, 0, 
     193    if(acl->url && pcre_exec(acl->url, NULL, uri_str, strlen(uri_str), 0, 0, 
    188194                             ovector, sizeof(ovector)/sizeof(*ovector)) <= 0) 
    189195      continue; 
     
    193199                               ovector, sizeof(ovector)/sizeof(*ovector)) <= 0) 
    194200        continue; 
    195       if(rule->url && pcre_exec(rule->url, NULL, restc->http_ctx->req.uri_str, 
    196                                 strlen(restc->http_ctx->req.uri_str), 0, 0, 
     201      if(rule->url && pcre_exec(rule->url, NULL, uri_str, strlen(uri_str), 0, 0, 
    197202                                ovector, sizeof(ovector)/sizeof(*ovector)) <= 0) 
    198203        continue; 
     
    282287int 
    283288noit_rest_request_dispatcher(noit_http_session_ctx *ctx) { 
    284   noit_http_rest_closure_t *restc = ctx->dispatcher_closure
     289  noit_http_rest_closure_t *restc = noit_http_session_dispatcher_closure(ctx)
    285290  rest_request_handler handler = restc->fastpath; 
    286291  if(!handler) handler = noit_http_get_handler(restc); 
    287292  if(handler) { 
     293    noit_http_response *res = noit_http_session_response(ctx); 
    288294    int rv; 
    289295    rv = handler(restc, restc->nparams, restc->params); 
    290     if(ctx->res.closed) noit_http_rest_clean_request(restc); 
     296    if(noit_http_response_closed(res)) noit_http_rest_clean_request(restc); 
    291297    return rv; 
    292298  } 
     
    395401                    int *mask, int *complete) { 
    396402  struct rest_xml_payload *rxc; 
     403  noit_http_request *req = noit_http_session_request(restc->http_ctx); 
     404 
    397405  if(restc->call_closure == NULL) { 
    398406    restc->call_closure = calloc(1, sizeof(*rxc)); 
     
    423431      return NULL; 
    424432    } 
    425     if(rxc->len == restc->http_ctx->req.content_length) { 
     433    if(rxc->len == noit_http_request_content_length(req)) { 
    426434      rxc->indoc = xmlParseMemory(rxc->buffer, rxc->len); 
    427435      rxc->complete = 1;