/* Action to run in response to the "test/output" URI */ static void output_action() { Output *output; /* Don't automatically finalize (complete) the request when this routine returns. This keeps the connection open. */ dontAutoFinalize(); /* Define the event notifier. We're interested in WRITABLE events */ setNotifier(output_callback); /* Open a file for output. Could use open/write, but we use the MPR equivalents for cross-platform I/O. */ output = mprAllocObj(Output, manageOutput); if ((output->file = mprOpenFile(OUTPUT_FILE, O_RDONLY, 0)) == 0) { httpError(getConn(), HTTP_CODE_INTERNAL_SERVER_ERROR, "Cannot open huge.txt"); return; } mprGetPathInfo(OUTPUT_FILE, &output->info); /* Save a reference to our output state */ setData(output); }
/* Action to run in response to the "test/echo" URI */ static void echo_action() { /* Don't automatically finalize (complete) the request when this routine returns. This keeps the connection open. */ dontAutoFinalize(); /* Establish the event callback */ espSetNotifier(getConn(), echo_callback); }
static void echo_action() { dontAutoFinalize(); httpSetConnNotifier(getConn(), echo_callback); }
static void dummy_action() { dontAutoFinalize(); httpSetConnNotifier(getConn(), dummy_callback); }
static void first() { dontAutoFinalize(); render("Hello "); setTimeout(second, 5000, getConn()); flush(); }