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); }
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); }
static void rest_test_check_result(struct check_test_closure *cl) { xmlDocPtr doc = NULL; xmlNodePtr root, state; noit_http_session_ctx *ctx = cl->restc->http_ctx; noitL(nlerr, "Flushing check test result\n"); if(cl->restc->call_closure_free) cl->restc->call_closure_free(cl->restc->call_closure); cl->restc->call_closure_free = NULL; cl->restc->call_closure = NULL; cl->restc->fastpath = NULL; if(ctx) { eventer_t conne = noit_http_connection_event(noit_http_session_connection(ctx)); doc = xmlNewDoc((xmlChar *)"1.0"); root = xmlNewDocNode(doc, NULL, (xmlChar *)"check", NULL); xmlDocSetRootElement(doc, root); state = noit_check_state_as_xml(cl->check); xmlAddChild(root, state); noit_http_response_ok(ctx, "text/xml"); noit_http_response_xml(ctx, doc); noit_http_response_end(ctx); if(conne) { // The event already exists, why re-add it? Did we want to update it? //eventer_add(conne); eventer_trigger(conne, EVENTER_READ | EVENTER_WRITE); } } noit_poller_free_check(cl->check); xmlFreeDoc(doc); free(cl); }