httr (version 0.6.1)

parse_media: Parse a media type.

Description

Parsed according to RFC 2616, as at http://pretty-rfc.herokuapp.com/RFC2616#media.types.

Usage

parse_media(x)

Arguments

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*@,;:\"/[]?={}
  • quoted-string = " *(any text except ", unless escaped with \) "

Examples

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

Run the code above in your browser using DataCamp Workspace