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
评论列表
文章目录