traversal.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:plone.server 作者: plone 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号