Skip to content

flush with fastcgi does not force headers to be sent #12385

Closed
@mvorisek

Description

@mvorisek

Description

The following code:

<?php

var_dump(headers_sent());

while (ob_get_level() !== 0) {
    ob_end_flush();
}
flush();

var_dump(headers_sent());
var_dump(ob_get_level());

Resulted in this output:

bool(false)
bool(false)
int(0)

But I expected this output instead:

bool(false)
bool(true)
int(0)

This issue is reproducible with fastcgi on Windows together with nginx.

When I output/echo any data, the headers are always sent (expected).

When I use the php internal webserver instead, the flush is enough to force the headers to be send without any data/body (expected).

I belive this is a bug, as sending headers early must be supported. Some apps might need non trivial amount of time until first byte of the response is ready, also, some apps might not output any body at all, and the headers are not sent until the script ends.

PHP Version

8.1

Operating System

Windows 10

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions