Skip to content

Commit

Permalink
Parsed cookies using SimpleCookie object
Browse files Browse the repository at this point in the history
  • Loading branch information
kbanc committed Jun 16, 2020
1 parent 07afd91 commit bda90d1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions httpie/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"""
import os
import re

from http.cookies import SimpleCookie
from pathlib import Path
from typing import Iterable, Optional, Union
from urllib.parse import urlsplit
Expand Down Expand Up @@ -79,10 +81,9 @@ def update_headers(self, request_headers: RequestHeadersDict):
if name == 'User-Agent' and value.startswith('HTTPie/'):
continue

if name == 'Cookie':
for cookie in value.split(';'):
name, value = cookie.split("=")
self['cookies'][name.strip()] = {'value': value.strip()}
if name.lower() == 'cookie':
for cookie_name, morsel in SimpleCookie(value).items():
self['cookies'][cookie_name] = {'value': morsel.value}
del request_headers['Cookie']
continue

Expand Down

0 comments on commit bda90d1

Please sign in to comment.