예제 #1
0
파일: json.py 프로젝트: uwevanopfern/falcon
 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
예제 #2
0
 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
예제 #3
0
파일: urlencoded.py 프로젝트: wsz/falcon
 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