flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.6k stars 407 forks source link

Have URL parameters available when setting streaming headers #554

Closed daniel-sc closed 3 months ago

daniel-sc commented 3 months ago

If I understand correctly, the URL parameters are not available when setting the streaming headers in streamWithHeaders. This is unfortunate, as one might like to set the filename or content-length in a header.

Is there a solution for this possible?

n0nag0n commented 3 months ago

So you actually can set whatever headers you want in your method, you just have to set them manually. I can update this in the docs. You'd do something like:


class MyController {
    public function someStreamMethod() {
        // must be a raw header
        header('Content-Disposition: attachment; filename=myfile.txt');
        // headers must be defined before you echo out anything.
        echo 'something';
    }
}
daniel-sc commented 3 months ago

@n0nag0n this would indeed resolve my problem - thanks!