parse_media: Parse a media type.

View source: R/media-parse.r

parse_mediaR Documentation

Parse a media type.

Description

Parsed according to RFC 2616, as at https://www.rfc-editor.org/rfc/rfc2616#section-3.7.

Usage

parse_media(x)

Arguments

x

String to parse

Details

A simplified minimal EBNF is:

  • media-type = ⁠type "/" subtype *( ";" parameter )⁠

  • type = token

  • subtype = token

  • parameter = ⁠attribute "=" value⁠

  • attribute = token

  • value = token | quoted-string

  • token = ⁠1*<any CHAR except CTLs or ()<>@,;:\"/[]?=\{\}⁠

Examples

parse_media("text/plain")
parse_media("text/plain; charset=utf-8")
parse_media("text/plain; charset=\"utf-8\"")
parse_media("text/plain; randomparam=\";=;=\"")

r-lib/httr documentation built on Nov. 5, 2023, 7:26 a.m.