base.py 文件源码

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

项目:fortiosclient 作者: jerryz1982 项目源码 文件源码
def format_cookie(cookie):
        if not cookie:
            return None
        try:
            fmt_headers = {}
            cookies = Cookie.SimpleCookie(cookie)
            for key, morsel in six.iteritems(cookies):
                if "ccsrftoken" in morsel.key:
                    morsel.coded_value = morsel.value
                    fmt_headers["X-CSRFTOKEN"] = morsel.value
                    break
            fmt_headers["Cookie"] = cookies.output(header="").lstrip()
            return fmt_headers
        except (Cookie.CookieError, KeyError):
            LOG.error(_LE("The cookie ccsrftoken cannot be formatted"))
            raise Cookie.CookieError
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号