Package Webutils': R Topics Documented
Package Webutils': R Topics Documented
R topics documented:
demo_httpuv .
demo_rhttpd . .
parse_http . . .
parse_multipart
parse_query . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Index
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2
2
2
3
4
5
parse_http
demo_httpuv
Description
Starts the httpuv web server and hosts a simple form including a file upload to demo the multipart
parser.
Usage
demo_httpuv(port)
Arguments
port
demo_rhttpd
Description
Starts the Rhttpd web server and hosts a simple form including a file upload to demo the multipart
parser.
Usage
demo_rhttpd()
parse_http
Description
Parse the body of a http request, based on the Content-Type request header. Currently supports
the three most important content types: application/x-www-form-urlencoded (parse_query),
multipart/form-data (parse_multipart) and application/json (fromJSON).
Usage
parse_http(body, content_type, ...)
parse_multipart
Arguments
body
content_type
...
Examples
# Parse json encoded payload:
parse_http('{"foo":123, "bar":true}', 'application/json')
# Parse url-encoded payload
parse_http("foo=1%2B1%3D2&bar=yin%26yang", "application/x-www-form-urlencoded")
## Not run: use demo app to parse multipart/form-data payload
demo_rhttpd()
## End(Not run)
parse_multipart
Description
Parse a multipart/form-data request, which is usually generated from a HTML form submission.
The parameters can include both text values as well as binary files. They can be distinguished from
the presence of a filename attribute.
Usage
parse_multipart(body, boundary)
Arguments
body
boundary
Details
A multipart/form-data request consists of a single body which contains one or more values plus
meta-data, separated using a boundary string. This boundary string is chosen by the client (e.g. the
browser) and specified in the Content-Type header of the HTTP request. There is no escaping; it
is up to the client to choose a boundary string that does not appear in one of the values.
The parser is written in pure R, but still pretty fast because it uses the regex engine.
parse_query
Examples
## Not run: example form
demo_rhttpd()
## End(Not run)
parse_query
Description
Parse http parameters from a query string. This includes unescaping of url-encoded values.
Usage
parse_query(query)
Arguments
query
Details
For http GET requests, the query string is specified in the URL after the question mark. For http
POST or PUT requests, the query string can be used in the request body when the Content-Type
header is set to application/x-www-form-urlencoded.
Examples
q <- "foo=1%2B1%3D2&bar=yin%26yang"
parse_query(q)
Index
demo_httpuv, 2
demo_rhttpd, 2
fromJSON, 2
parse_http, 2
parse_multipart, 2, 3
parse_query, 2, 4