add.header.Rd
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.
add.header(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
.
Character vector of the resulting headers
## 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")
}