mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
msgpack data is binary, open in binary mode
This commit is contained in:
parent
8fa8d5c5b5
commit
ad95c0e8cf
@ -218,12 +218,12 @@ def query(url,
|
|||||||
# proper cookie jar. Unfortunately, since session cookies do not
|
# proper cookie jar. Unfortunately, since session cookies do not
|
||||||
# contain expirations, they can't be stored in a proper cookie jar.
|
# contain expirations, they can't be stored in a proper cookie jar.
|
||||||
if os.path.isfile(session_cookie_jar):
|
if os.path.isfile(session_cookie_jar):
|
||||||
with salt.utils.fopen(session_cookie_jar, 'r') as fh_:
|
with salt.utils.fopen(session_cookie_jar, 'rb') as fh_:
|
||||||
session_cookies = msgpack.load(fh_)
|
session_cookies = msgpack.load(fh_)
|
||||||
if isinstance(session_cookies, dict):
|
if isinstance(session_cookies, dict):
|
||||||
header_dict.update(session_cookies)
|
header_dict.update(session_cookies)
|
||||||
else:
|
else:
|
||||||
with salt.utils.fopen(session_cookie_jar, 'w') as fh_:
|
with salt.utils.fopen(session_cookie_jar, 'wb') as fh_:
|
||||||
msgpack.dump('', fh_)
|
msgpack.dump('', fh_)
|
||||||
|
|
||||||
for header in header_list:
|
for header in header_list:
|
||||||
@ -462,7 +462,7 @@ def query(url,
|
|||||||
if persist_session is True and HAS_MSGPACK:
|
if persist_session is True and HAS_MSGPACK:
|
||||||
# TODO: See persist_session above
|
# TODO: See persist_session above
|
||||||
if 'set-cookie' in result_headers:
|
if 'set-cookie' in result_headers:
|
||||||
with salt.utils.fopen(session_cookie_jar, 'w') as fh_:
|
with salt.utils.fopen(session_cookie_jar, 'wb') as fh_:
|
||||||
session_cookies = result_headers.get('set-cookie', None)
|
session_cookies = result_headers.get('set-cookie', None)
|
||||||
if session_cookies is not None:
|
if session_cookies is not None:
|
||||||
msgpack.dump({'Cookie': session_cookies}, fh_)
|
msgpack.dump({'Cookie': session_cookies}, fh_)
|
||||||
|
Loading…
Reference in New Issue
Block a user