add.header: Add HTML headers to FastRWeb response.

View source: R/tools.R

add.headerR Documentation

Add HTML headers to FastRWeb response.

Description

add.header appends additional headers to the HTML reponse when using WebResult with any other command than "raw".

This is useful for handling of cookies (see getCookies() in the sample common.R script), cache-behavior, implementing URL redirection etc.

Usage

add.header(txt)

Arguments

txt

character vector of header entires. The string may NOT include any CR/LF characters, those will be automatically generated when the final response is constructed. Elements of the vector should represent lines. It is user's responsibility to ensure the entries are valid according to the HTTP standard. Also note that you should never add either Content-type: or Content-length: headers as those are always generated automatically from the WebResult.

Value

Character vector of the resulting headers

Author(s)

Simon Urbanek

See Also

WebResult

Examples

## main.css.R: serve a static file (main.css) with cache control
run <- function(...) {
  # last for at most an hour
  add.header("Cache-Control: max-age=3600")
  WebResult("file", "main.css", "text/css")
}

s-u/FastRWeb documentation built on Dec. 1, 2023, 12:41 a.m.