if (SG(headers_sent) && !SG(request_info).headers_only) {
OG(php_body_write) = php_ub_body_write_no_header;
} else {
- if (!OG(active_ob_buffer).erase) /* Set Content-Length only if unerasable */
+ /* Set Content-Length only if unerasable */
+ if (!OG(active_ob_buffer).erase && status == (PHP_OUTPUT_HANDLER_START|PHP_OUTPUT_HANDLER_END))
ADD_CL_HEADER(OG(active_ob_buffer).text_length);
OG(php_body_write) = php_ub_body_write;
}