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 with parse_query(), multipart/form-data with parse_multipart(), and application/json with jsonlite::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 Oct. 4, 2024, 9:06 a.m.