Parse http request

Share:

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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)