static int (*php_output_direct)(const char *str, size_t str_len) = php_output_stderr;
/* }}} */
+/* {{{ void php_output_header(TSRMLS_D) */
+static void php_output_header(TSRMLS_D)
+{
+ if (!SG(headers_sent)) {
+ if (!OG(output_start_filename)) {
+ if (zend_is_compiling(TSRMLS_C)) {
+ OG(output_start_filename) = zend_get_compiled_filename(TSRMLS_C);
+ OG(output_start_lineno) = zend_get_compiled_lineno(TSRMLS_C);
+ } else if (zend_is_executing(TSRMLS_C)) {
+ OG(output_start_filename) = zend_get_executed_filename(TSRMLS_C);
+ OG(output_start_lineno) = zend_get_executed_lineno(TSRMLS_C);
+ }
+#if PHP_OUTPUT_DEBUG
+ fprintf(stderr, "!!! output started at: %s (%d)\n", OG(output_start_filename), OG(output_start_lineno));
+#endif
+ }
+ if (!php_header(TSRMLS_C)) {
+ OG(flags) |= PHP_OUTPUT_DISABLED;
+ }
+ }
+}
+/* }}} */
+
/* {{{ void php_output_startup(void)
* Set up module globals and initalize the conflict and reverse conflict hash tables */
PHPAPI void php_output_startup(void)
{
php_output_handler **handler = NULL;
+ php_output_header(TSRMLS_C);
+
+ OG(flags) ^= PHP_OUTPUT_ACTIVATED;
OG(active) = NULL;
OG(running) = NULL;
zend_stack_destroy(&OG(handlers));
}
- OG(flags) ^= PHP_OUTPUT_ACTIVATED;
}
/* }}} */
}
if (context.out.data && context.out.used) {
+ php_output_header(TSRMLS_C);
+
+ if (!(OG(flags) & PHP_OUTPUT_DISABLED)) {
#if PHP_OUTPUT_DEBUG
- fprintf(stderr, "::: sapi_write('%s', %zu)\n", context.out.data, context.out.used);
+ fprintf(stderr, "::: sapi_write('%s', %zu)\n", context.out.data, context.out.used);
#endif
- if (!SG(headers_sent) && php_header(TSRMLS_C)) {
- if (zend_is_compiling(TSRMLS_C)) {
- OG(output_start_filename) = zend_get_compiled_filename(TSRMLS_C);
- OG(output_start_lineno) = zend_get_compiled_lineno(TSRMLS_C);
- } else if (zend_is_executing(TSRMLS_C)) {
- OG(output_start_filename) = zend_get_executed_filename(TSRMLS_C);
- OG(output_start_lineno) = zend_get_executed_lineno(TSRMLS_C);
+ sapi_module.ub_write(context.out.data, context.out.used TSRMLS_CC);
+
+ if (OG(flags) & PHP_OUTPUT_IMPLICITFLUSH) {
+ sapi_flush(TSRMLS_C);
}
-#if PHP_OUTPUT_DEBUG
- fprintf(stderr, "!!! output started at: %s (%d)\n", OG(output_start_filename), OG(output_start_lineno));
-#endif
- }
- sapi_module.ub_write(context.out.data, context.out.used TSRMLS_CC);
- if (OG(flags) & PHP_OUTPUT_IMPLICITFLUSH) {
- sapi_flush(TSRMLS_C);
+
+ OG(flags) |= PHP_OUTPUT_SENT;
}
- OG(flags) |= PHP_OUTPUT_SENT;
}
php_output_context_dtor(&context);
}
static void append_http_status_line(smart_str *buffer, int protocol_version, int response_code, int persistent) /* {{{ */
{
+ if (!response_code) {
+ response_code = 200;
+ }
smart_str_appendl_ex(buffer, "HTTP", 4, persistent);
smart_str_appendc_ex(buffer, '/', persistent);
smart_str_append_generic_ex(buffer, protocol_version / 100, persistent, int, _unsigned);
int err = 0;
zval *style = NULL;
zend_try {
- php_output_activate(TSRMLS_C);
php_output_start_user(NULL, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC);
php_info_print_style(TSRMLS_C);
MAKE_STD_ZVAL(style);
php_output_get_contents(style TSRMLS_CC);
php_output_discard(TSRMLS_C);
- php_output_deactivate(TSRMLS_C);
if (style && Z_STRVAL_P(style)) {
char *block = pestrndup(Z_STRVAL_P(style), Z_STRLEN_P(style), 1);
php_cli_server_chunk *chunk = php_cli_server_chunk_heap_new(block, block, Z_STRLEN_P(style));