Changeset 6de024fe1a245773c4b8c107f9063f2f40e5c344

Show
Ignore:
Timestamp:
01/05/11 02:42:51 (3 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_http.c

    r1e1b047 r6de024f  
    4747#define HEADER_EXPECT "expect" 
    4848 
     49struct noit_http_connection { 
     50  eventer_t e; 
     51  int needs_close; 
     52}; 
     53 
     54struct noit_http_request { 
     55  struct bchain *first_input; /* The start of the input chain */ 
     56  struct bchain *last_input;  /* The end of the input chain */ 
     57  struct bchain *current_input;  /* The point of the input where we */ 
     58  size_t         current_offset; /* analyzing. */ 
     59 
     60  enum { NOIT_HTTP_REQ_HEADERS = 0, 
     61         NOIT_HTTP_REQ_EXPECT, 
     62         NOIT_HTTP_REQ_PAYLOAD } state; 
     63  struct bchain *current_request_chain; 
     64  noit_boolean has_payload; 
     65  int64_t content_length; 
     66  int64_t content_length_read; 
     67  char *method_str; 
     68  char *uri_str; 
     69  char *protocol_str; 
     70  noit_hash_table querystring; 
     71  u_int32_t opts; 
     72  noit_http_method method; 
     73  noit_http_protocol protocol; 
     74  noit_hash_table headers; 
     75  noit_boolean complete; 
     76  struct timeval start_time; 
     77  char *orig_qs; 
     78}; 
     79 
     80struct noit_http_response { 
     81  noit_http_protocol protocol; 
     82  int status_code; 
     83  char *status_reason; 
     84 
     85  noit_hash_table headers; 
     86  struct bchain *leader; /* serialization of status line and headers */ 
     87 
     88  u_int32_t output_options; 
     89  struct bchain *output;       /* data is pushed in here */ 
     90  struct bchain *output_raw;   /* internally transcoded here for output */ 
     91  size_t output_raw_offset;    /* tracks our offset */ 
     92  noit_boolean output_started; /* locks the options and leader */ 
     93                               /*   and possibly output. */ 
     94  noit_boolean closed;         /* set by _end() */ 
     95  noit_boolean complete;       /* complete, drained and disposable */ 
     96  size_t bytes_written;        /* tracks total bytes written */ 
     97}; 
     98 
     99struct noit_http_session_ctx { 
     100  noit_atomic32_t ref_cnt; 
     101  int64_t drainage; 
     102  int max_write; 
     103  noit_http_connection conn; 
     104  noit_http_request req; 
     105  noit_http_response res; 
     106  noit_http_dispatch_func dispatcher; 
     107  void *dispatcher_closure; 
     108  acceptor_closure_t *ac; 
     109}; 
     110 
    49111static noit_log_stream_t http_debug = NULL; 
    50112static noit_log_stream_t http_io = NULL; 
     
    125187  n->size = size; 
    126188  return n; 
     189} 
     190 
     191noit_http_request * 
     192noit_http_session_request(noit_http_session_ctx *ctx) { 
     193  return &ctx->req; 
     194} 
     195noit_http_response * 
     196noit_http_session_response(noit_http_session_ctx *ctx) { 
     197  return &ctx->res; 
     198} 
     199noit_http_connection * 
     200noit_http_session_connection(noit_http_session_ctx *ctx) { 
     201  return &ctx->conn; 
     202} 
     203void 
     204noit_http_session_set_dispatcher(noit_http_session_ctx *ctx, 
     205                                 int (*d)(noit_http_session_ctx *), void *dc) { 
     206  ctx->dispatcher = d; 
     207  ctx->dispatcher_closure = dc; 
     208} 
     209void *noit_http_session_dispatcher_closure(noit_http_session_ctx *ctx) { 
     210  return ctx->dispatcher_closure; 
     211} 
     212void noit_http_session_trigger(noit_http_session_ctx *ctx, int state) { 
     213  if(ctx->conn.e) eventer_trigger(ctx->conn.e, state); 
     214} 
     215uint32_t noit_http_session_ref_cnt(noit_http_session_ctx *ctx) { 
     216  return ctx->ref_cnt; 
     217} 
     218uint32_t noit_http_session_ref_dec(noit_http_session_ctx *ctx) { 
     219  return noit_atomic_dec32(&ctx->ref_cnt); 
     220} 
     221uint32_t noit_http_session_ref_inc(noit_http_session_ctx *ctx) { 
     222  return noit_atomic_inc32(&ctx->ref_cnt); 
     223} 
     224eventer_t noit_http_connection_event(noit_http_connection *conn) { 
     225  return conn->e; 
     226} 
     227const char *noit_http_request_uri_str(noit_http_request *req) { 
     228  return req->uri_str; 
     229} 
     230const char *noit_http_request_method_str(noit_http_request *req) { 
     231  return req->method_str; 
     232} 
     233const char *noit_http_request_protocol_str(noit_http_request *req) { 
     234  return req->protocol_str; 
     235} 
     236size_t noit_http_request_content_length(noit_http_request *req) { 
     237  return req->content_length; 
     238} 
     239const char *noit_http_request_querystring(noit_http_request *req, const char *k) { 
     240  void *vv; 
     241  const char *v = NULL; 
     242  if(noit_hash_retrieve(&req->querystring, k, strlen(k), &vv)) 
     243    v = vv; 
     244  return v; 
     245} 
     246noit_hash_table *noit_http_request_querystring_table(noit_http_request *req) { 
     247  return &req->querystring; 
     248} 
     249noit_hash_table *noit_http_request_headers_table(noit_http_request *req) { 
     250  return &req->headers; 
     251} 
     252noit_boolean noit_http_response_closed(noit_http_response *res) { 
     253  return res->closed; 
    127254} 
    128255 
  • src/noit_http.h

    r68a5668 r6de024f  
    5858} bchain_type_t; 
    5959 
     60struct bchain; 
     61 
     62#define DEFAULT_MAXWRITE 1<<14 /* 32k */ 
     63#define DEFAULT_BCHAINSIZE ((1 << 15)-(offsetof(struct bchain, _buff))) 
     64/* 64k - delta */ 
     65#define DEFAULT_BCHAINMINREAD (DEFAULT_BCHAINSIZE/4) 
     66#define BCHAIN_SPACE(a) ((a)->allocd - (a)->size - (a)->start) 
     67 
     68struct noit_http_connection; 
     69typedef struct noit_http_connection noit_http_connection; 
     70struct noit_http_request; 
     71typedef struct noit_http_request noit_http_request; 
     72struct noit_http_response; 
     73typedef struct noit_http_response noit_http_response; 
     74 
    6075struct bchain { 
    6176  bchain_type_t type; 
     
    6883}; 
    6984 
    70 #define DEFAULT_MAXWRITE 1<<14 /* 32k */ 
    71 #define DEFAULT_BCHAINSIZE ((1 << 15)-(offsetof(struct bchain, _buff))) 
    72 /* 64k - delta */ 
    73 #define DEFAULT_BCHAINMINREAD (DEFAULT_BCHAINSIZE/4) 
    74 #define BCHAIN_SPACE(a) ((a)->allocd - (a)->size - (a)->start) 
    75  
    76 typedef struct { 
    77   eventer_t e; 
    78   int needs_close; 
    79 } noit_http_connection; 
    80  
    81 typedef struct { 
    82   struct bchain *first_input; /* The start of the input chain */ 
    83   struct bchain *last_input;  /* The end of the input chain */ 
    84   struct bchain *current_input;  /* The point of the input where we */ 
    85   size_t         current_offset; /* analyzing. */ 
    86  
    87   enum { NOIT_HTTP_REQ_HEADERS = 0, 
    88          NOIT_HTTP_REQ_EXPECT, 
    89          NOIT_HTTP_REQ_PAYLOAD } state; 
    90   struct bchain *current_request_chain; 
    91   noit_boolean has_payload; 
    92   int64_t content_length; 
    93   int64_t content_length_read; 
    94   char *method_str; 
    95   char *uri_str; 
    96   char *protocol_str; 
    97   noit_hash_table querystring; 
    98   u_int32_t opts; 
    99   noit_http_method method; 
    100   noit_http_protocol protocol; 
    101   noit_hash_table headers; 
    102   noit_boolean complete; 
    103   struct timeval start_time; 
    104   char *orig_qs; 
    105 } noit_http_request; 
    106  
    107 typedef struct { 
    108   noit_http_protocol protocol; 
    109   int status_code; 
    110   char *status_reason; 
    111  
    112   noit_hash_table headers; 
    113   struct bchain *leader; /* serialization of status line and headers */ 
    114  
    115   u_int32_t output_options; 
    116   struct bchain *output;       /* data is pushed in here */ 
    117   struct bchain *output_raw;   /* internally transcoded here for output */ 
    118   size_t output_raw_offset;    /* tracks our offset */ 
    119   noit_boolean output_started; /* locks the options and leader */ 
    120                                /*   and possibly output. */ 
    121   noit_boolean closed;         /* set by _end() */ 
    122   noit_boolean complete;       /* complete, drained and disposable */ 
    123   size_t bytes_written;        /* tracks total bytes written */ 
    124 } noit_http_response; 
    125  
    12685struct noit_http_session_ctx; 
    127 typedef int (*noit_http_dispatch_func) (struct noit_http_session_ctx *); 
    128  
    129 typedef struct noit_http_session_ctx { 
    130   noit_atomic32_t ref_cnt; 
    131   int64_t drainage; 
    132   int max_write; 
    133   noit_http_connection conn; 
    134   noit_http_request req; 
    135   noit_http_response res; 
    136   noit_http_dispatch_func dispatcher; 
    137   void *dispatcher_closure; 
    138   acceptor_closure_t *ac; 
    139 } noit_http_session_ctx; 
     86typedef struct noit_http_session_ctx noit_http_session_ctx; 
     87typedef int (*noit_http_dispatch_func) (noit_http_session_ctx *); 
    14088 
    14189API_EXPORT(noit_http_session_ctx *) 
     
    14492API_EXPORT(void) 
    14593  noit_http_ctx_session_release(noit_http_session_ctx *ctx); 
     94API_EXPORT(uint32_t) 
     95  noit_http_session_ref_cnt(noit_http_session_ctx *); 
     96API_EXPORT(uint32_t) 
     97  noit_http_session_ref_dec(noit_http_session_ctx *); 
     98API_EXPORT(uint32_t) 
     99  noit_http_session_ref_inc(noit_http_session_ctx *); 
     100API_EXPORT(void) 
     101  noit_http_session_trigger(noit_http_session_ctx *, int state); 
    146102 
     103API_EXPORT(noit_http_request *) 
     104  noit_http_session_request(noit_http_session_ctx *); 
     105API_EXPORT(noit_http_response *) 
     106  noit_http_session_response(noit_http_session_ctx *); 
     107API_EXPORT(noit_http_connection *) 
     108  noit_http_session_connection(noit_http_session_ctx *); 
     109 
     110API_EXPORT(void *) 
     111  noit_http_session_dispatcher_closure(noit_http_session_ctx *); 
     112API_EXPORT(void) 
     113  noit_http_session_set_dispatcher(noit_http_session_ctx *, 
     114                                   int (*)(noit_http_session_ctx *), void *); 
     115 
     116API_EXPORT(eventer_t) 
     117  noit_http_connection_event(noit_http_connection *); 
     118 
     119API_EXPORT(const char *) 
     120  noit_http_request_uri_str(noit_http_request *); 
     121API_EXPORT(const char *) 
     122  noit_http_request_method_str(noit_http_request *); 
     123API_EXPORT(const char *) 
     124  noit_http_request_protocol_str(noit_http_request *); 
     125API_EXPORT(size_t) 
     126  noit_http_request_content_length(noit_http_request *); 
     127API_EXPORT(const char *) 
     128  noit_http_request_querystring(noit_http_request *, const char *); 
     129API_EXPORT(noit_hash_table *) 
     130  noit_http_request_querystring_table(noit_http_request *); 
     131API_EXPORT(noit_hash_table *) 
     132  noit_http_request_headers_table(noit_http_request *); 
     133 
     134API_EXPORT(noit_boolean) 
     135  noit_http_response_closed(noit_http_response *); 
    147136 
    148137API_EXPORT(void) 
  • 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; 
  • src/stratcon_jlog_streamer.c

    rd9a21af r6de024f  
    10751075  noit_hash_iter iter = NOIT_HASH_ITER_ZERO; 
    10761076  char path[256]; 
    1077   void *key_id, *vstr
     1077  void *key_id
    10781078  const char *type = NULL, *want_cn = NULL; 
    10791079  int klen, n = 0, i, di, cnt; 
     
    10831083  struct timeval now, diff, last; 
    10841084  xmlNodePtr node; 
    1085  
    1086   noit_http_process_querystring(&restc->http_ctx->req); 
    1087   if(noit_hash_retrieve(&restc->http_ctx->req.querystring, "type", 4, &vstr)) 
    1088     type = vstr; 
    1089   if(noit_hash_retrieve(&restc->http_ctx->req.querystring, "cn", 2, &vstr)) 
    1090     want_cn = vstr; 
     1085  noit_http_request *req = noit_http_session_request(restc->http_ctx); 
     1086 
     1087  noit_http_process_querystring(req); 
     1088  type = noit_http_request_querystring(req, "type"); 
     1089  want_cn = noit_http_request_querystring(req, "cn"); 
    10911090 
    10921091  gettimeofday(&now, NULL); 
     
    13531352rest_set_noit(noit_http_rest_closure_t *restc, 
    13541353              int npats, char **pats) { 
    1355   void *vcn; 
    13561354  const char *cn = NULL; 
    13571355  noit_http_session_ctx *ctx = restc->http_ctx; 
     1356  noit_http_request *req = noit_http_session_request(ctx); 
    13581357  unsigned short port = 43191; 
    13591358  if(npats < 1 || npats > 2) 
    13601359    noit_http_response_server_error(ctx, "text/xml"); 
    13611360  if(npats == 2) port = atoi(pats[1]); 
    1362   noit_http_process_querystring(&ctx->req); 
    1363   if(noit_hash_retrieve(&ctx->req.querystring, "cn", 2, &vcn)) 
    1364     cn = vcn; 
     1361  noit_http_process_querystring(req); 
     1362  cn = noit_http_request_querystring(req, "cn"); 
    13651363  if(stratcon_add_noit(pats[0], port, cn) >= 0) 
    13661364    noit_http_response_ok(ctx, "text/xml"); 
  • src/stratcon_realtime_http.c

    r8c720f9 r6de024f  
    115115  char *scp, *ecp, *token; 
    116116  int len; 
    117   void *vcb; 
    118117  const char *v, *cb = NULL; 
    119118  noit_hash_table json = NOIT_HASH_EMPTY; 
     119  noit_http_request *req = noit_http_session_request(ctx); 
    120120  char s_inc_id[42]; 
    121121 
    122122  snprintf(s_inc_id, sizeof(s_inc_id), "script-%08x", inc_id); 
    123   if(noit_hash_retrieve(&ctx->req.querystring, "cb", strlen("cb"), &vcb)) 
    124     cb = vcb; 
     123  
     124  cb = noit_http_request_querystring(req, "cb");  
    125125  for(v = cb; v && *v; v++) 
    126126    if(!((*v >= '0' && *v <= '9') || 
     
    162162  if(buff[1] == '\t' && (buff[0] == 'M' || buff[0] == 'S')) { 
    163163    char target[256], module[256], name[256], uuid_str[UUID_STR_LEN+1]; 
     164    noit_http_request *req = noit_http_session_request(ctx); 
     165    noit_hash_table *qs; 
    164166    noit_hash_iter iter = NOIT_HASH_ITER_ZERO; 
    165167    const char *key; 
     
    174176    ra_write(buffer, strlen(buffer)); 
    175177 
    176     while(noit_hash_next(&ctx->req.querystring, &iter, &key, &klen, &vval)) { 
     178    qs = noit_http_request_querystring_table(req); 
     179    while(noit_hash_next(qs, &iter, &key, &klen, &vval)) { 
    177180      if(!strcmp(key, "cb")) continue; 
    178181      noit_hash_store(&json, key, klen, strdup(vval ?(char *)vval : "true")); 
     
    262265} 
    263266int 
    264 stratcon_realtime_uri_parse(realtime_context *rc, char *uri) { 
     267stratcon_realtime_uri_parse(realtime_context *rc, const char *uri) { 
    265268  int len, cnt = 0; 
    266   char *cp, *copy, *interest, *brk; 
     269  const char *cp, *interest; 
     270  char *copy, *brk; 
    267271  if(strncmp(uri, "/data/", 6)) return 0; 
    268272  cp = uri + 6; 
     
    300304  realtime_recv_ctx_t *rrctx = vctx; 
    301305  noit_http_session_ctx *ctx = rrctx->ctx; 
    302   realtime_context *rc = ctx->dispatcher_closure
    303  
    304   if(noit_atomic_dec32(&ctx->ref_cnt) == 1) { 
     306  realtime_context *rc = noit_http_session_dispatcher_closure(ctx)
     307 
     308  if(noit_http_session_ref_dec(ctx) == 1) { 
    305309    noit_http_response_end(ctx); 
    306310    clear_realtime_context(rc); 
    307     if(ctx->conn.e) eventer_trigger(ctx->conn.e, EVENTER_WRITE | EVENTER_EXCEPTION); 
     311    noit_http_session_trigger(ctx, EVENTER_WRITE | EVENTER_EXCEPTION); 
    308312  } 
    309313  free(rrctx); 
     
    444448                                   struct timeval *now) { 
    445449  noit_http_session_ctx *ctx = closure; 
    446   realtime_context *rc = ctx->dispatcher_closure
     450  realtime_context *rc = noit_http_session_dispatcher_closure(ctx)
    447451  struct realtime_tracker *node; 
    448452 
     
    459463    } 
    460464    else 
    461       noit_atomic_dec32(&ctx->ref_cnt); 
    462   } 
    463   if(ctx->ref_cnt == 1) { 
     465      noit_http_session_ref_dec(ctx); 
     466  } 
     467  if(noit_http_session_ref_cnt(ctx) == 1) { 
    464468    noit_http_response_end(ctx); 
    465469    clear_realtime_context(rc); 
    466     if(ctx->conn.e) eventer_trigger(ctx->conn.e, EVENTER_WRITE); 
     470    noit_http_session_trigger(ctx, EVENTER_WRITE); 
    467471  } 
    468472  return 0; 
     
    471475stratcon_request_dispatcher(noit_http_session_ctx *ctx) { 
    472476  const char *key, *value; 
    473   realtime_context *rc = ctx->dispatcher_closure
     477  realtime_context *rc = noit_http_session_dispatcher_closure(ctx)
    474478  int klen; 
    475479  noit_hash_iter iter = NOIT_HASH_ITER_ZERO; 
    476   noit_http_request *req = &ctx->req
     480  noit_http_request *req = noit_http_session_request(ctx)
    477481 
    478482  if(rc->setup == RC_INITIAL) { 
     
    481485    char c[1024]; 
    482486    int num_interests; 
    483  
    484     num_interests = stratcon_realtime_uri_parse(rc, ctx->req.uri_str); 
     487    const char *uri_str = noit_http_request_uri_str(req); 
     488    noit_hash_table *headers = noit_http_request_headers_table(req); 
     489 
     490    num_interests = stratcon_realtime_uri_parse(rc, uri_str); 
    485491    if(num_interests == 0) { 
    486492      noit_http_response_status_set(ctx, 404, "OK"); 
     
    491497 
    492498    noitL(noit_error, "http: %s %s %s\n", 
    493           req->method_str, req->uri_str, req->protocol_str); 
    494     while(noit_hash_next_str(&req->headers, &iter, &key, &klen, &value)) { 
     499          noit_http_request_method_str(req), uri_str, 
     500          noit_http_request_protocol_str(req)); 
     501    while(noit_hash_next_str(headers, &iter, &key, &klen, &value)) { 
    495502      noitL(noit_error, "http: [%s: %s]\n", key, value); 
    496503    } 
     
    515522    for(node = rc->checklist; node; node = node->next) { 
    516523      char uuid_str[UUID_STR_LEN+1]; 
    517       noit_atomic_inc32(&ctx->ref_cnt); 
     524      noit_http_session_ref_inc(ctx); 
    518525      uuid_unparse_lower(node->checkid, uuid_str); 
    519526      noitL(noit_error, "Resolving uuid: %s\n", uuid_str); 
     
    545552  const char *document_domain = NULL; 
    546553  noit_http_session_ctx *ctx = restc->http_ctx; 
     554  noit_http_connection *conn = noit_http_session_connection(ctx); 
     555  eventer_t e; 
    547556  acceptor_closure_t *ac = restc->ac; 
    548557 
     
    560569  } 
    561570 
    562   noit_http_process_querystring(&ctx->req); 
     571  noit_http_process_querystring(noit_http_session_request(ctx)); 
    563572  /* Rewire the http context */ 
    564   ctx->conn.e->callback = stratcon_realtime_http_handler; 
    565   ctx->dispatcher = stratcon_request_dispatcher; 
    566   ctx->dispatcher_closure = alloc_realtime_context(document_domain); 
     573  e = noit_http_connection_event(conn); 
     574  e->callback = stratcon_realtime_http_handler; 
     575  noit_http_session_set_dispatcher(ctx, stratcon_request_dispatcher, 
     576                                   alloc_realtime_context(document_domain)); 
    567577  return stratcon_request_dispatcher(ctx); 
    568578}