The Accept
HTTP header is able to specify parameters to each Media type that it references.
text/html;level=2;q=0.4, */*;q=0.5
Is it possible to quote a parameter such that it can include otherwise non-allowed characters?
This is mostly a thought experiment at the moment, but here's my use case:
Consider a hypothetical multipart media type. Call it multipart/multiformat
. It has several pre-defined parts, call them apart
and bpart
. Those parts each can be any valid media type.
What I'd like to be able to do is essentially mimic the Accept
header in the parameters for the media type. For instance:
multipart/multiformat;apart="text/html, */*;q=0.8";bpart="text/*", */*;q=0.4
In the example above, the quotes are intended to allow anything in the parameters. Of course, even if this works, we'll have conflicting issues again (with the double-quotes this time) if we want to use the multipart/multiformat
media type as one of the parts of the top-level multipart/multiformat
document. Yay recursion.
Is what I'm trying to do possible? Is there a better approach?
Yes, the value of a media type parameter can be a quoted-string:
media-type = type "/" subtype *( ";" parameter )
type = token
subtype = token
(see http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7)
where a "parameter" can be:
parameter = attribute "=" value
attribute = token
value = token | quoted-string
(see http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6)
So the specific example you mention is definitely syntactically valid.
multipart/multiformat;apart="text/html, */*;q=0.8";bpart="text/*", */*;q=0.4