예제 #1
0
 def decode_return_content(res, response=None):
     if 'content-type' in res.headers and res.headers['content-type'] == "application/bson":
         tmp = decode_bson(res.content)
         if response is not None:
             response_server = BiiResponse.deserialize(tmp["info"])
             response_server.biiout(response)
         return tmp["return"]
     else:
         return res.content
예제 #2
0
 def decode_return_content(res, response=None):
     if 'content-type' in res.headers and res.headers[
             'content-type'] == "application/bson":
         tmp = decode_bson(res.content)
         if response is not None:
             response_server = BiiResponse.deserialize(tmp["info"])
             response_server.biiout(response)
         return tmp["return"]
     else:
         return res.content
예제 #3
0
 def _getBson(self):
     ''' If the ``Content-Type`` header is ``application/bson``, this
         property holds the parsed content of the request body. Only requests
         smaller than :attr:`MEMFILE_MAX` are processed to avoid memory
         exhaustion. '''
     max_size = BII_MAX_MEMORY_PER_REQUEST
     if request.headers['Content-Type'] == 'application/bson':
         if 0 < request.content_length < max_size:
             return decode_bson(request.body.read(max_size))
         else:
             logger.error("Max size of bson for request: %i" % request.content_length)
             # DO NOT REMOVE: BODY NEEDS TO BE READED BEFORE RAISE, IT SEEMS LIKE A BOTTLE BUG
             request.body.read(0)
             raise BSONBottlePluginException("Max request size overtaken")
     else:
         raise BSONBottlePluginException("Not Bson request in a method with bson_param specified")
     return None