Learn R Programming

FastRWeb (version 1.2-1)

add.header: 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)

Value

Character vector of the resulting headers

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.

Author

Simon Urbanek

See Also

WebResult

Examples

Run this code
## 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")
}

Run the code above in your browser using DataLab