Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » HTTPResponse object

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

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

Page: 1
Go to End
Author Topic: 1291 Views
  • Sam
    Avatar
    Administrator
    679 Posts

    HTTPResponse object Link to this post

    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?

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: HTTPResponse object Link to this post

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

  • Markus
    Avatar
    Google Summer of Code Hacker
    152 Posts

    Re: HTTPResponse object Link to this post

    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.

    1291 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.