I am trying to understand why this was a bug and why throwing an Exception is a good idea.
I agree it is not best to send headers again and in the previous version it just failed silently, which I think is the proper thing to do. Now starting in 2.0.14 it is throwing an ErrorException even though everything could be ok.
Couldn’t we just create a log entry or something instead of completely error-ing and breaking anything that didn’t use Yii’s Response.
Could say something like "[Warning] yii\web\Response - Headers already sent"
It looks to me a good decision of the developers to throw the exception. Every error should be promptly revealed. IMO "silent failure" is the worst kind of behavior in the framework which will disturb us in developing/debugging an app.
If you it is your intention to send again the header just do a try catch and manage the exception. So it is clear at code level that this is the intended behavior.
I follow this topic.
I am generating large XML (with repeated calls flush()). But what now?
How can I generate large XML and send batch output to browser?
Please help or link to example. Thanks.