gabrielfalcao/HTTPretty — pull request #88 by toumorokoshi (2013-07-29 07:44:17+00:00)
Title: Adding parsed_body parameter to simplify checks

Sorry about not replying on #81, somehow it missed my radar.

I added some tests, and decided to add a bit of extra functionality as well that I think will serve people better in the future.

This pull request adds an additional parameter parsed_body to HTTPrettyRequest:

parsed_body attempts to parse the body if it matches a compatible content type
* content is returned unaltered if it's not a compatible type
* content parses json if content-type type is application/json
* content parse querystring params if content-type is application/x-www-form-urlencoded
* if the value cannot be parsed for any reason (e.g. invalid json), it is unaltered

I was considering adding xml parsing, but I think xml.elementree/minidom as something to work with is a bit more complicated and less intuitive than the dictionary/lists representation of json and querystrings, so I figure that parsing is up to a user's discretion.