Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

HTTPResponse object

Go to End

3 Posts   1638 Views


Administrator, 690 Posts

17 August 2007 at 2:20pm

In order to support testability of controller objects with PHPUnit, I am changing the way that Controller handles redirections.

$controller->run() will now return an HTTPResponse object, which will store headers (including redirection headers) as well as the HTTP body.

Director now calls the output() method on HTTPRepsonse, which will output all the headers and the body.

$output = $controller->run(...);

However, if other applications, such as PHPUnit, can instead interrogate the HTTPReponse object to see if a redirection was triggered, for example:

$output = $controller->run(...);
$this->assertEqual($output->getStatusCode(), 302);



Administrator, 690 Posts

17 August 2007 at 3:17pm

This has been implemented here:


Google Summer of Code Hacker, 152 Posts

18 August 2007 at 2:55am

The introduction of the HTTPResponse object broke some of my and the forum's code. I fixed it already (r40437 and r40439).

There was also a bug in the Director class: Director::redirectBack() didn't work because it stopped the script before outputting the headers.