Header

server.header() method is used to set or unset HTTP response header.

server.header(string <name>, string <value>, bool <replace>, int<code>) : void

Parameters

This method required name, value parameter optional  replace and code .

To unset header set value to nil

name
HTTP Header Name

value

HTTP Header Value

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.

code

Optional HTTP Response Status Code

Return Values

No value is returned.

Examples

Example #1 Set Content Type Header

This will display system default page:

server.header("content-type", "text/plain");

Example #2 Set Custom Header

server.header("test", "this is test header", true);

Example #2 Remove  Header

server.header("test", nil);