当前位置: 首页>>代码示例>>Python>>正文


Python Request.path_info方法代码示例

本文整理汇总了Python中swift.common.swob.Request.path_info方法的典型用法代码示例。如果您正苦于以下问题:Python Request.path_info方法的具体用法?Python Request.path_info怎么用?Python Request.path_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在swift.common.swob.Request的用法示例。


在下文中一共展示了Request.path_info方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

# 需要导入模块: from swift.common.swob import Request [as 别名]
# 或者: from swift.common.swob.Request import path_info [as 别名]
    def __call__(self, env, start_response):
        request = Request(env)
        try:
            (version, account, container, objname) = split_path(request.path_info, 1, 4, True)
        except ValueError:
            response = request.get_response(self.app)
            return response(env, start_response)
        if not objname:
            response = request.get_response(self.app)
            if container:
                if not request.params.has_key('compress'):
                    response.body = response.body.replace(self.compress_suffix, '')
            return response(env, start_response)

        original_path_info = request.path_info
        request.path_info += self.compress_suffix
        if request.method == 'GET':
            if not request.params.has_key('compress'):
                # we need to decompress
                response = request.get_response(self.app)

                if response.status_int == 404:
                    # it may not be compressed, if admin added the compress filter after 
                    # some files have been uploaded
                    request.path_info = original_path_info
                    response = request.get_response(self.app)
                    return response(env, start_response)
                uncompressed_data = create_uncompress(response.body)
                response.body = uncompressed_data
                return response(env, start_response)
       
        if request.method == 'PUT':
            if hasattr(request, 'body_file'):
                data = ""
                while True:
                    chunk = request.body_file.read()
                    if not chunk:
                        break
                    data += chunk
                request.body = data
                compress_data = create_compress(data)
            else:
                compress_data = create_compress(request.body)
            if compress_data:
                request.body = compress_data

        response = request.get_response(self.app)
        return response(env, start_response)
开发者ID:xczheng,项目名称:swift-encrypt-compress-middleware,代码行数:50,代码来源:compress.py

示例2: _initialize

# 需要导入模块: from swift.common.swob import Request [as 别名]
# 或者: from swift.common.swob.Request import path_info [as 别名]
    def _initialize(self):
        resp = None

        if self.swift_client:
            resp = self.swift_client.make_request('HEAD', self.path, {},
                                                  (2, 4))
        elif self.env:
            req = Request(self.env)
            req.method = 'HEAD'
            req.path_info = self.path
            req.headers['Content-Length'] = '0'
            resp = req.get_response(self.app)

        if resp is None:
            return

        self.status = resp.status_int

        if is_success(self.status):
            self.headers = resp.headers
开发者ID:KoreaCloudObjectStorage,项目名称:swift-lifecycle-management,代码行数:22,代码来源:lifecycle.py


注:本文中的swift.common.swob.Request.path_info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。