def subrequest(
orig_request, path, relative_to_site=True,
headers={}, body=None, params=None, method='GET'):
"""Subrequest, initial implementation doing a real request."""
session = aiohttp.ClientSession()
method = method.lower()
if method not in SUBREQUEST_METHODS:
raise AttributeError('No valid method ' + method)
caller = getattr(session, method)
for head in orig_request.headers:
if head not in headers:
headers[head] = orig_request.headers[head]
params = {
'headers': headers,
'params': params
}
if method in ['put', 'patch']:
params['data'] = body
return caller(path, **params)
评论列表
文章目录