-
Notifications
You must be signed in to change notification settings - Fork 328
Description
IMO Response#parse with implicit MIME-type guessed from response Content-Type must be discouraged:
HTTP.get("http://example.com").parseThe snippet above will raise:
HTTP::Error: Unknown MIME type: text/html
Although error message is clear, I don't see how this API can be good to use. Let's say one will define parser for text/html that will be returning Nokogiri::Document. So now, #parse will be returning Nokogiri::Document if content type is text/html, Array or Hash if content type is application/json... There's no way one will be able to work with that without some sort of wrapper (or just branching based on type) to neglect differences between Nokogiri::Document and plain Array or Hash loaded from JSON.
So probably we should make mime type argument required.
PS Users of Oj may find this API less performant than Oj.load(res) as latter one will utilize streaming.