parse_http: Parse http request

View source: R/parse_http.R

parse_httpR Documentation

Parse http request

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, ...)

Arguments

body

request body of the http request

content_type

content-type http request header as specified by the client

...

additional arguments passed to parser function

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)

webutils documentation built on Nov. 24, 2023, 5:11 p.m.