+/* {{{ STATUS http_exit(int, char*, char*) */
+STATUS _http_exit_ex(int status, char *header, char *body, zend_bool send_header TSRMLS_DC)
+{
+ if ( (send_header && (SUCCESS != http_send_status_header(status, header))) ||
+ (status && (SUCCESS != http_send_status(status)))) {
+ http_error_ex(HE_WARNING, HTTP_E_HEADER, "Failed to exit with status/header: %d - %s", status, STR_PTR(header));
+ STR_FREE(header);
+ STR_FREE(body);
+ return FAILURE;
+ }
+
+ if (!OG(ob_lock)) {
+ php_end_ob_buffers(0 TSRMLS_CC);
+ }
+ if ((SUCCESS == sapi_send_headers(TSRMLS_C)) && body) {
+ PHPWRITE(body, strlen(body));
+ }
+
+ switch (status) {
+ case 301: http_log(HTTP_G->log.redirect, "301-REDIRECT", header); break;
+ case 302: http_log(HTTP_G->log.redirect, "302-REDIRECT", header); break;
+ case 303: http_log(HTTP_G->log.redirect, "303-REDIRECT", header); break;
+ case 305: http_log(HTTP_G->log.redirect, "305-REDIRECT", header); break;
+ case 307: http_log(HTTP_G->log.redirect, "307-REDIRECT", header); break;
+ case 304: http_log(HTTP_G->log.cache, "304-CACHE", header); break;
+ case 404: http_log(HTTP_G->log.not_found, "404-NOTFOUND", NULL); break;
+ case 405: http_log(HTTP_G->log.allowed_methods, "405-ALLOWED", header); break;
+ default: http_log(NULL, header, body); break;
+ }
+
+ STR_FREE(header);
+ STR_FREE(body);
+
+ if (HTTP_G->force_exit) {
+ zend_bailout();
+ } else {
+ php_ob_set_internal_handler(http_ob_blackhole, 4096, "blackhole", 0 TSRMLS_CC);
+ }
+
+ return SUCCESS;
+}
+/* }}} */