本文整理汇总了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
示例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))
示例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))
示例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'))
示例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))