power-media / prado3

Automatically exported from code.google.com/p/prado3
Other
0 stars 0 forks source link

THttpResponse::redirect() fails if output buffering has been disabled completely #393

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run attached testcase (which tries a simple redirect when opened, but has 
buffering explicitly disabled at startup) (make sure you have buffering_output 
disabled in your php.ini!)

What is the expected output? What do you see instead?
The browser should get redirected to www.example.com. Instead you get the error 
message:

[Warning] Cannot modify header information - headers already sent (@line 437 in 
file Prado\framework\Web\THttpResponse.php).

What version of the product are you using? On what operating system?
Prado/trunk

Please provide any additional information below.
Fixed THttpResponse attached. 

The bug is masked in the default configuration, because the value of 
BufferOutput defaults to true, and even if set to false from the 
application.xml configuration, the value will be applied to the property only 
after buffering has actually begun. (This also means that you can't actually 
completely disable buffering from application.xml, even though this does not 
cause any problem, unless you do a redirect). The bug gets exposed only if you 
circumvent this inherent limitation with a custom THttpResponse-derivant and 
disable buffering explicitly in the contructor/init. (Also, if you didn't 
disable buffering in php.ini the testcase might not fail to redirect, as 
expected, because there will be actually buffering taking place on the PHP 
level.)

Original issue reported on code.google.com by google...@pcforum.hu on 24 Mar 2012 at 6:43

Attachments:

GoogleCodeExporter commented 8 years ago
Sorry, the correct name of the php.ini setting to set is output_buffering. 
Should be set to "off" to disable automatic output buffering at PHP level.

Original comment by google...@pcforum.hu on 24 Mar 2012 at 6:46

GoogleCodeExporter commented 8 years ago
patch committed in r3119, thank you

Original comment by ctrlal...@gmail.com on 25 Mar 2012 at 3:53