views:

1368

answers:

4
+9  Q: 

YAML mime type?

What is the most appropriate MIME type to use when sending data structured with YAML over HTTP?

An explanation of why a given choice is most appropriate would be much appreciated.

There is no registered application type or text type that I can see.

Example:

> GET /example.yaml

< Content-Type: ????
<
< --- # Favorite movies
< - Casablanca
< - North by Northwest
< - Notorious

Possible options:

text/yaml
text/x-yaml
application/yaml
application/x-yaml
+4  A: 

http://dev.rubyonrails.org/svn/rails/trunk/actionpack/lib/action_controller/mime_types.rb

Ruby on Rails uses application/x-yaml with an alternative of text/yaml.

I think it's just a matter of convention, there is no technical why, afaict.

Vinko Vrsalovic
Weird, google for "yaml mime" gives a ruby link as the first hit, with text/x-yaml and no mention of application/x-yaml
Greg
+3  A: 

I'd say text/x-yaml:

text over application because it's a human-readable

x-yaml over yaml because it hasn't been accepted into the registered list of mime types.

Edit: from RFC 3023 (XML Media Types):

The top-level media type "text" has some restrictions on MIME entities and they are described in [RFC2045] and [RFC2046]. In particular, the UTF-16 family, UCS-4, and UTF-32 are not allowed (except over HTTP[RFC2616], which uses a MIME-like mechanism).

Interesting... Not exactly sure what it means, but food for thought.

Greg
It's human readable but its intent is to communicate applications... XML is under application
Vinko Vrsalovic
And also under text. It seems you'd have to have both text/x-yaml and application/x-yaml... http://www.rfc-editor.org/rfc/rfc3023.txt
Vinko Vrsalovic
A: 

I know this is ugly, but use text/plain if you want to display it in a browser and have it formatted correctly - all of the above will default to a download in IE or Firefox.

Richard Wheeldon
A: 

"x-" media types are discouraged, see RFC 4288, Section 3.4. The right thing to do is to use the personal tree, the vendor tree, or to actually attempt a proper media type registration.

Julian Reschke