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


Python Request.headers['X-Backend-Inbound-X-Timestamp']方法代码示例

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


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

示例1: __call__

# 需要导入模块: from swift.common.swob import Request [as 别名]
# 或者: from swift.common.swob.Request import headers['X-Backend-Inbound-X-Timestamp'] [as 别名]
    def __call__(self, env, start_response):
        req = Request(env)
        removed = remove_items(req.headers, self.inbound_condition)
        if removed:
            self.logger.debug('removed request headers: %s' % removed)

        if 'X-Timestamp' in req.headers and self.shunt_x_timestamp:
            ts = req.headers.pop('X-Timestamp')
            req.headers['X-Backend-Inbound-X-Timestamp'] = ts
            # log in a similar format as the removed headers
            self.logger.debug('shunted request headers: %s' %
                              [('X-Timestamp', ts)])

        def gatekeeper_response(status, response_headers, exc_info=None):
            removed = filter(
                lambda h: self.outbound_condition(h[0]),
                response_headers)
            if removed:
                self.logger.debug('removed response headers: %s' % removed)
                new_headers = filter(
                    lambda h: not self.outbound_condition(h[0]),
                    response_headers)
                return start_response(status, new_headers, exc_info)
            return start_response(status, response_headers, exc_info)
        return self.app(env, gatekeeper_response)
开发者ID:Ahiknsr,项目名称:swift,代码行数:27,代码来源:gatekeeper.py

示例2: __call__

# 需要导入模块: from swift.common.swob import Request [as 别名]
# 或者: from swift.common.swob.Request import headers['X-Backend-Inbound-X-Timestamp'] [as 别名]
    def __call__(self, env, start_response):
        req = Request(env)
        removed = remove_items(req.headers, self.inbound_condition)
        if removed:
            self.logger.debug('removed request headers: %s' % removed)

        if 'X-Timestamp' in req.headers and self.shunt_x_timestamp:
            ts = req.headers.pop('X-Timestamp')
            req.headers['X-Backend-Inbound-X-Timestamp'] = ts
            # log in a similar format as the removed headers
            self.logger.debug('shunted request headers: %s' %
                              [('X-Timestamp', ts)])

        def gatekeeper_response(status, response_headers, exc_info=None):
            def fixed_response_headers():
                def relative_path(value):
                    parsed = urlsplit(v)
                    new_path = parsed.path
                    if parsed.query:
                        new_path += ('?%s' % parsed.query)
                    if parsed.fragment:
                        new_path += ('#%s' % parsed.fragment)
                    return new_path

                if not env.get('swift.leave_relative_location'):
                    return response_headers
                else:
                    return [
                        (k, v) if k.lower() != 'location' else
                        (k, relative_path(v)) for (k, v) in response_headers
                    ]

            response_headers = fixed_response_headers()
            removed = filter(
                lambda h: self.outbound_condition(h[0]),
                response_headers)

            if removed:
                self.logger.debug('removed response headers: %s' % removed)
                new_headers = filter(
                    lambda h: not self.outbound_condition(h[0]),
                    response_headers)
                return start_response(status, new_headers, exc_info)
            return start_response(status, response_headers, exc_info)
        return self.app(env, gatekeeper_response)
开发者ID:chenzhongtao,项目名称:swift,代码行数:47,代码来源:gatekeeper.py


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