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


Python util.is_hop_by_hop方法代码示例

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


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

示例1: _download_remote_file

# 需要导入模块: from wsgiref import util [as 别名]
# 或者: from wsgiref.util import is_hop_by_hop [as 别名]
def _download_remote_file(self, ledger_field, asset):
        node_id = asset['owner']
        auth = authenticate_outgoing_request(node_id)
        r = get_remote_file(asset[ledger_field]['storageAddress'], auth, stream=True)
        if not r.ok:
            return Response({
                'message': f'Cannot proxify asset from node {asset["owner"]}: {str(r.text)}'
            }, status=r.status_code)

        response = CustomFileResponse(
            streaming_content=(chunk for chunk in r.iter_content(512 * 1024)),
            status=r.status_code)

        for header in r.headers:
            # We don't use hop_by_hop headers since they are incompatible
            # with WSGI
            if not is_hop_by_hop(header):
                response[header] = r.headers.get(header)

        return response 
开发者ID:SubstraFoundation,项目名称:substra-backend,代码行数:22,代码来源:utils.py

示例2: test_response_headers_are_not_in_hop_by_hop_headers

# 需要导入模块: from wsgiref import util [as 别名]
# 或者: from wsgiref.util import is_hop_by_hop [as 别名]
def test_response_headers_are_not_in_hop_by_hop_headers(self):
        path = "/"
        request = self.factory.get(path)
        headers = {
            'connection': '0',
            'proxy-authorization': 'allow',
            'content-type': 'text/html',
        }

        urlopen_mock = get_urlopen_mock(headers=headers)
        with patch(URLOPEN, urlopen_mock):
            response = CustomProxyView.as_view()(request, path=path)

        response_headers = response._headers

        for header in response_headers:
            self.assertFalse(is_hop_by_hop(header)) 
开发者ID:danpoland,项目名称:drf-reverse-proxy,代码行数:19,代码来源:test_response.py

示例3: testHopByHop

# 需要导入模块: from wsgiref import util [as 别名]
# 或者: from wsgiref.util import is_hop_by_hop [as 别名]
def testHopByHop(self):
        for hop in (
            "Connection Keep-Alive Proxy-Authenticate Proxy-Authorization "
            "TE Trailers Transfer-Encoding Upgrade"
        ).split():
            for alt in hop, hop.title(), hop.upper(), hop.lower():
                self.assertTrue(util.is_hop_by_hop(alt))

        # Not comprehensive, just a few random header names
        for hop in (
            "Accept Cache-Control Date Pragma Trailer Via Warning"
        ).split():
            for alt in hop, hop.title(), hop.upper(), hop.lower():
                self.assertFalse(util.is_hop_by_hop(alt)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:test_wsgiref.py

示例4: set_response_headers

# 需要导入模块: from wsgiref import util [as 别名]
# 或者: from wsgiref.util import is_hop_by_hop [as 别名]
def set_response_headers(response, response_headers):
    for header, value in response_headers.items():
        if is_hop_by_hop(header) or header.lower() == 'set-cookie':
            continue

        response[header.title()] = value

    logger.debug('Response headers: %s', getattr(response, '_headers')) 
开发者ID:danpoland,项目名称:drf-reverse-proxy,代码行数:10,代码来源:utilites.py

示例5: testHopByHop

# 需要导入模块: from wsgiref import util [as 别名]
# 或者: from wsgiref.util import is_hop_by_hop [as 别名]
def testHopByHop(self):
        for hop in (
            "Connection Keep-Alive Proxy-Authenticate Proxy-Authorization "
            "TE Trailers Transfer-Encoding Upgrade"
        ).split():
            for alt in hop, hop.title(), hop.upper(), hop.lower():
                self.failUnless(util.is_hop_by_hop(alt))

        # Not comprehensive, just a few random header names
        for hop in (
            "Accept Cache-Control Date Pragma Trailer Via Warning"
        ).split():
            for alt in hop, hop.title(), hop.upper(), hop.lower():
                self.failIf(util.is_hop_by_hop(alt)) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:16,代码来源:test_wsgiref.py


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