def _deserialize(self, data): if not data: raise errors.MediaNotFoundError('JSON') try: return self.loads(data.decode()) except ValueError as err: raise errors.MediaMalformedError('JSON') from err
def _deserialize(self, data): if not data: raise errors.MediaNotFoundError('MessagePack') try: # NOTE(jmvrbanac): Using unpackb since we would need to manage # a buffer for Unpacker() which wouldn't gain us much. return self._unpackb(data, raw=False) except ValueError as err: raise errors.MediaMalformedError('MessagePack') from err
def _deserialize(self, body): try: # NOTE(kgriffs): According to http://goo.gl/6rlcux the # body should be US-ASCII. Enforcing this also helps # catch malicious input. body = body.decode('ascii') return parse_query_string(body, keep_blank=self._keep_blank, csv=self._csv) except Exception as err: raise errors.MediaMalformedError('URL-encoded') from err