function exit_with_mojo_flush_response($req, $response) { if (is_valid_response($response)) { exit_with($response); } exit_with(glue_response($req, $response)); }
function valid_response($response) { if (!is_valid_response($response)) { $status_code = STATUS_OK; $headers = array(); if (is_array($response)) { if (isset($response['status_code'])) { $status_code = $response['status_code']; unset($response['status_code']); } if (isset($response['headers']) and is_array($response['headers'])) { $headers = $response['headers']; unset($response['headers']); } } $response = response_($status_code, $headers, $response); } return $response; }