django.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:maas 作者: maas 项目源码 文件源码
def parse_headers_and_body_with_mimer(cls, headers, body):
        """Use piston's Mimer functionality to handle the content.

        :return: The value of 'request.data' after using Piston's
            translate_mime on the input.
        """
        # JAM 2012-10-09 Importing emitters has a side effect of registering
        #   mime type handlers with utils.translate_mime.
        from piston3 import emitters
        emitters  # Imported for side-effects.
        from piston3.utils import translate_mime

        environ = {'wsgi.input': BytesIO(body.encode("utf8"))}
        for name, value in headers.items():
            environ[name.upper().replace('-', '_')] = value
        environ['REQUEST_METHOD'] = 'POST'
        environ['SCRIPT_NAME'] = ''
        environ['PATH_INFO'] = ''
        from django.core.handlers.wsgi import WSGIRequest
        request = WSGIRequest(environ)
        translate_mime(request)
        return request.data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号