Skip to content

Commit fbf6ea5

Browse files
authored
Proposed solution for Issue #104: multiple cookies
Patch so that the _parse_headers function handles multiple cookies by appending them, separated by a comma and space. See lines 361-364. This mimics the behaviour of Python requests when it comes to response.headers['set-cookie'] and response.headers.items(). Currently this function just writes over any previous cookie, leaving only the last one. Thrilled to be submitting my first public pull request. Thanks to @askpatrickw and @tekktrik for their encouragement.
1 parent 947bf5c commit fbf6ea5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

adafruit_requests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,10 @@ def _parse_headers(self) -> None:
358358
self._remaining = int(content)
359359
if title == "transfer-encoding":
360360
self._chunked = content.strip().lower() == "chunked"
361-
self._headers[title] = content
361+
if title == "set-cookie" and title in self._headers:
362+
self._headers[title] = self._headers[title] + ", " + content
363+
else:
364+
self._headers[title] = content
362365

363366
def _validate_not_gzip(self) -> None:
364367
"""gzip encoding is not supported. Raise an exception if found."""

0 commit comments

Comments
 (0)