cgiRequest: Create a CGI Request Object

Description Usage Arguments Details Value Note References Examples

Description

A request object is created from the appropriate environment variables and is returned as a list. List elements include:

Usage

1
cgiRequest(testParams = NULL)

Arguments

testParams

URL request parameters for testing GET requests

Details

Even in the modern era (>= 2017) it is still sometimes useful to build simple web services using CGI scripts. Benefits include: ease of coding; use of standard port 80; service uptime: even if the CGI script dies while handling an earlier request, the script will be restarted for the next request.

Using this function, the body of an R CGI script can begin with:

1
2
3
4
req <- cgiRequest()
headers <- req$params
params <- req$params
...

Value

A list containing CGI request elements

Note

The returned object mimics the request object created in the jug package.

References

https://github.com/Bart6114/jug/blob/master/R/request.R

Examples

1
2
3
4
# Example borrowed from webutils::parse_query
q <- "foo=1%2B1%3D2&bar=yin%26yang"
req <- cgiRequest(q)
str(req$params)

MazamaWebUtils documentation built on May 2, 2019, 2:41 a.m.