Skip to contents

See https://developer.mozilla.org/en-US/docs/Glossary/Response_header for example response headers and their purpose.

Usage

header(..., expose = FALSE, name = ...names(), value = ..1)

Arguments

...

A single key-value pair.

expose

Allow javascript to read this header.

name

Explicitly set the name (key) in the key-value pair.

value

Explicitly set the value in the key-value pair.

Value

A 'header' object that can be passed to response().

Examples


    library(webqueue)
    
    header(name = 'Location', value = '/index.html')
#> Location: /index.html
    
    Location <- '/index.html'
    header(Location)
#> Location: /index.html
    
    response(307L, header(Location = '/index.html'))
#> HTTP/1.1 307 Temporary Redirect
#> Location: /index.html
#> 
#> Temporary Redirect
    
    # Allow javascript to access a header value
    header('x-user-id' = 100, expose = TRUE)
#> x-user-id: 100
#> Access-Control-Expose-Headers: x-user-id