Sets the raw HTTP-Header.


Syntax

header (string $header, bool $replace = true, int $response_code = 0): void


Parameter

@param string $header The HTTP header string.

@param bool $replace The optional replace parameter indicates whether the header should replace a previous similar header, or add a second header of the same type. By default it will replace, but if you pass in false as the second argument you can force multiple headers of the same type.

@param int $response_code Forces the HTTP response code to the specified value. Note that this parameter only has an effect if the header is not empty.


Return

This function does not return anything.


Examples

Writing in your twig source code:

Download Dialog (CSV file):

{% do hublify.header('Content-Type: application/csv') %}
{% do hublify.header('Content-Disposition: attachment; filename="download.csv"') %}
{% do hublify.header('Pragma: no-cache') %}

{# ... generate your CSV-output, here ... #}


Caching directive:

{% do hublify.header("Cache-Control: no-cache, must-revalidate") %}
{% do hublify.header("Expires: Sat, 26 Jul 1997 05:00:00 GMT") %