HTTP Response Headers
This posts brings together several related pieces of Virtuoso Server Pages documentation.
First, we’ll handle HTTP Headers. To set a header in VSP, one can use
However, contrary to intuition, using this command a second time doesn’t set a second header entry, but replaces the last one. To “accumulate” custom headers entries, one must use
http_header ( concat (http_header_get (), string));
Please not that string must end in “\r\n”. http_header.get () returns the currently built up header entries so the line above appends a new entry to the accumulated header entries.
An example from description.vsp of the DBpedia plugin:
http_header ( concat (http_header_get (), sprintf ('Expires: %s \r\n', date_rfc1123 (dateadd ('day', 7, now ())))));
http_header ( concat (http_header_get (), 'Set-Cookie: dbpv_has_js=0\r\n'));
Accessing HTTP Request Header (for cookies)
To access the HTTP request header in VSP, one can use:
To access some entry (“Cookie” for example) in the request header, the following line should be used:
http_request_header (http_request_header (), 'Cookie', null, '');
This line returns all cookie information included in the Request header. To get some value from the cookie, one can use the following:
get_keyword ('cookie_value', split_and_decode (cookie, 0, ';='), '');