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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   1808 Views

Avatar
Sam

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(...);
$output->output();

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);

Thoughts?

Avatar
Sam

Administrator, 690 Posts

17 August 2007 at 3:17pm

This has been implemented here: http://open.silverstripe.com/changeset/40392

Avatar
Markus

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.