static int
rest_stream_data(noit_http_rest_closure_t *restc,
                 int npats, char **pats) {
  /* We're here and want to subvert the rest system */
  const char *document_domain = NULL;
  noit_http_session_ctx *ctx = restc->http_ctx;
  noit_http_connection *conn = noit_http_session_connection(ctx);
  eventer_t e;
  acceptor_closure_t *ac = restc->ac;

  /* Rewire the handler */
  if(ac->service_ctx_free)
    ac->service_ctx_free(ac->service_ctx);
  ac->service_ctx = ctx;
  ac->service_ctx_free = noit_http_ctx_acceptor_free;

  if(!noit_hash_retr_str(ac->config,
                         "document_domain", strlen("document_domain"),
                         &document_domain)) {
    noitL(noit_error, "Document domain not set!  Realtime streaming will be broken\n");
    document_domain = "";
  }

  noit_http_process_querystring(noit_http_session_request(ctx));
  /* Rewire the http context */
  e = noit_http_connection_event(conn);
  e->callback = stratcon_realtime_http_handler;
  noit_http_session_set_dispatcher(ctx, stratcon_request_dispatcher,
                                   alloc_realtime_context(document_domain));
  return stratcon_request_dispatcher(ctx);
}
Esempio n. 2
0
static int
handoff_stream(noit_http_rest_closure_t *restc, int npats, char **pats) {
  noit_http_session_ctx *ctx = restc->http_ctx;
  noit_http_connection *conn = noit_http_session_connection(ctx);
  eventer_t e;
  acceptor_closure_t *ac = restc->ac;

  if(ac->service_ctx_free)
    ac->service_ctx_free(ac->service_ctx);
  ac->service_ctx = ctx;
  ac->service_ctx_free = noit_http_ctx_acceptor_free;

  e = noit_http_connection_event(conn);
  e->callback = handoff_http_handler;
  noit_http_session_set_dispatcher(ctx, handoff_request_dispatcher, NULL);
  return handoff_request_dispatcher(ctx);
}