def parse_response(resp, content, strict=False, content_type=None):
 if (not content_type):
  content_type = resp.headers.get('content-type', 'application/json')
 (ct, options) = parse_options_header(content_type)
 if (ct in ('application/json', 'text/javascript')):
  if (not content):
   return {}
  return json.loads(content)
 if (ct in ('application/xml', 'text/xml')):
  return get_etree().fromstring(content)
 if ((ct != 'application/x-www-form-urlencoded') and strict):
  return content
 charset = options.get('charset', 'utf-8')
 return url_decode(content, charset=charset).to_dict()

def parse_response ( resp , content , strict = False , content_type = None ) : if ( not content_type ) : content_type = resp . headers . get ( 'content-type' , 'application/json' ) ( ct , options ) = parse_options_header ( content_type ) if ( ct in ( 'application/json' , 'text/javascript' ) ) : if ( not content ) : return { } return json . loads ( content ) if ( ct in ( 'application/xml' , 'text/xml' ) ) : return get_etree ( ) . fromstring ( content ) if ( ( ct != 'application/x-www-form-urlencoded' ) and strict ) : return content charset = options . get ( 'charset' , 'utf-8' ) return url_decode ( content , charset = charset ) . to_dict ( )
try and parse response as an http response .