Repository: miguelgrinberg/python-engineio

Issue:
Failing to parse cookie with an equal in its value
This line
https://github.com/miguelgrinberg/python-engineio/blob/7fa9575954f4e14794d5458107522d858c08f69e/engineio/asyncio_client.py#L252
causes a cookie with an equal in its value to throw an exception like
``ValueError: dictionary update sequence element #0 has length 3; 2 is required``

The fix for that could be:
```
[cookie.split('=', 1) for cookie in value.split('; ')])
```

Discussion:

Patch:
diff --git a/engineio/asyncio_client.py b/engineio/asyncio_client.py
index 5ee6f11..896e62f 100644
--- a/engineio/asyncio_client.py
+++ b/engineio/asyncio_client.py
@@ -249,7 +249,7 @@ class AsyncClient(client.Client):
         for header, value in headers.items():
             if header.lower() == 'cookie':
                 cookies = dict(
-                    [cookie.split('=') for cookie in value.split('; ')])
+                    [cookie.split('=', 1) for cookie in value.split('; ')])
                 del headers[header]
                 break
         self.http.cookie_jar.update_cookies(cookies)


Test patch:
diff --git a/tests/asyncio/test_asyncio_client.py b/tests/asyncio/test_asyncio_client.py
index e81235c..055c2d9 100644
--- a/tests/asyncio/test_asyncio_client.py
+++ b/tests/asyncio/test_asyncio_client.py
@@ -617,14 +617,16 @@ class TestAsyncClient(unittest.TestCase):
         on_connect = mock.MagicMock()
         c.on('connect', on_connect)
         _run(c.connect('ws://foo',
-                       headers={'Cookie': 'key=value; key2=value2'},
+                       headers={
+                           'Cookie': 'key=value; key2=value2; key3="value3="'
+                       },
                        transports=['websocket']))
         time.sleep(0.1)
         c.http.ws_connect.mock.assert_called_once_with(
             'ws://foo/engine.io/?transport=websocket&EIO=3&t=123.456',
             headers={})
         c.http.cookie_jar.update_cookies.assert_called_once_with(
-            {'key': 'value', 'key2': 'value2'})
+            {'key': 'value', 'key2': 'value2', 'key3': '"value3="'})
 
     @mock.patch('engineio.client.time.time', return_value=123.456)
     def test_websocket_connection_with_cookies_and_headers(self, _time):