siesta icon indicating copy to clipboard operation
siesta copied to clipboard

Replace ad hoc content type handling in Entity w/MediaType struct

Open pcantrell opened this issue 10 years ago • 0 comments

Entity’s handling of media types has several related subtle flaws:

  • Entity returns the content type as an unparsed string, which maybe contain obscure media type options (text/x.vnd.crazy+plain; charset=utf-8; vndparam=whatever) and thus be difficult to work with.
  • Related to the above, the nice media type matching available to ResponseTransformers isn't available anywhere else.
  • The code leans on NSHTTPURLResponse to extract the charset, which means that charset is confusingly a stored property where contentType and etag are derived from headers. This means that (1) contentType and charset can conflict, and (2) charset is an annoying special case in the init & serialization code.

A nice solution to all these things would be to expose a robust MediaType struct instead of a raw string. Something to do after all the basics are in place.

pcantrell avatar Aug 24 '15 20:08 pcantrell