'Attempt to parse the post based on the content-type passed. Return the regular body if not'

def parse_request_body(self, body):

    PARSING_FUNCTIONS = {u'application/json': json.loads, u'text/json': json.loads, u'application/x-www-form-urlencoded': self.parse_querystring}
    FALLBACK_FUNCTION = (lambda x: x)
    content_type = self.headers.get(u'content-type', u'')
    do_parse = PARSING_FUNCTIONS.get(content_type, FALLBACK_FUNCTION)
    try:
        body = decode_utf8(body)
        return do_parse(body)
    except:
        return body
