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.

Archive /

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

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

HTTPResponse object


Reply


3 Posts   1345 Views

Avatar
Sam

Administrator, 685 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, 685 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.