The aim of the HeaderManager is to send HTTP headers to the client. Beyond this, the class guarantees, that URLs generated with the LinkGenerator can be used as well.

The following static methods are available for use by the developer:

  • forward(): Forwards to the desired target url.
  • redirect(): Redirects the user to the desired url. You can descide to send permanent redirect status or not.
  • send(): This method is a generic function, that can be used to send any HTTP header (e.g. content-type, ...). For details, please have a look at www.faqs.org/rfcs/rfc2616.

The following code box shows a typical examples:

PHP code
use APF\tools\http\HeaderManager; use APF\tools\link\LinkGenerator; use APF\tools\link\Url; $link = LinkGenerator::generateUrl( Url::fromCurrent()->mergeQuery(array('param1' => '','param2' => 'new_value')) ); HeaderManager::forward($link);

Both methods forward() and redirect() abort further code execution using exit() to avoid code injection (see Overview of Execution After Redirect Web Application Vulnerabilities).

To switch off the default behaviour you may want to use HeaderManager's deactivateExitAfterForward() or activateExitAfterForward() methods to either globally switch this feature off or on.

To deactivate abortion with a dedicated forward() or redirect() call you can apply the optional $exitAfterForward parameter set to false.


Do you want to add a comment to the article above, or do you want to post additional hints? So please click here. Comments already posted can be found below.
There are no comments belonging to this article.

In order to provide a state-of-the-art web experience and to continuously improve our services we are using cookies. By using this web page you agree to the use of cookies. For more information, please refer to our Privacy policy.