From c2603e9ddc7ff96a8fe7beced751aea1480ec5e6 Mon Sep 17 00:00:00 2001 From: Tobias <22522058+sirkrypt0@users.noreply.github.com> Date: Fri, 17 Sep 2021 15:04:09 +0200 Subject: [PATCH] Use plaintext Content-Type when using polling (#248) --- src/engineio/asyncio_client.py | 2 +- src/engineio/client.py | 2 +- tests/asyncio/test_asyncio_client.py | 10 +++++----- tests/common/test_client.py | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/engineio/asyncio_client.py b/src/engineio/asyncio_client.py index 9301e0a9..930c8f5e 100644 --- a/src/engineio/asyncio_client.py +++ b/src/engineio/asyncio_client.py @@ -586,7 +586,7 @@ async def _write_loop(self): p = payload.Payload(packets=packets) r = await self._send_request( 'POST', self.base_url, body=p.encode(), - headers={'Content-Type': 'application/octet-stream'}, + headers={'Content-Type': 'text/plain'}, timeout=self.request_timeout) for pkt in packets: self.queue.task_done() diff --git a/src/engineio/client.py b/src/engineio/client.py index ba5ce975..16ac5b4f 100644 --- a/src/engineio/client.py +++ b/src/engineio/client.py @@ -680,7 +680,7 @@ def _write_loop(self): p = payload.Payload(packets=packets) r = self._send_request( 'POST', self.base_url, body=p.encode(), - headers={'Content-Type': 'application/octet-stream'}, + headers={'Content-Type': 'text/plain'}, timeout=self.request_timeout) for pkt in packets: self.queue.task_done() diff --git a/tests/asyncio/test_asyncio_client.py b/tests/asyncio/test_asyncio_client.py index bea49e1c..7440b54b 100644 --- a/tests/asyncio/test_asyncio_client.py +++ b/tests/asyncio/test_asyncio_client.py @@ -1211,7 +1211,7 @@ def test_write_loop_polling_one_packet(self): 'POST', 'http://foo', body=p.encode(), - headers={'Content-Type': 'application/octet-stream'}, + headers={'Content-Type': 'text/plain'}, timeout=5, ) @@ -1252,7 +1252,7 @@ def test_write_loop_polling_three_packets(self): 'POST', 'http://foo', body=p.encode(), - headers={'Content-Type': 'application/octet-stream'}, + headers={'Content-Type': 'text/plain'}, timeout=5, ) @@ -1288,7 +1288,7 @@ def test_write_loop_polling_two_packets_done(self): 'POST', 'http://foo', body=p.encode(), - headers={'Content-Type': 'application/octet-stream'}, + headers={'Content-Type': 'text/plain'}, timeout=5, ) assert c.state == 'connected' @@ -1316,7 +1316,7 @@ def test_write_loop_polling_bad_connection(self): 'POST', 'http://foo', body=p.encode(), - headers={'Content-Type': 'application/octet-stream'}, + headers={'Content-Type': 'text/plain'}, timeout=5, ) assert c.state == 'connected' @@ -1345,7 +1345,7 @@ def test_write_loop_polling_bad_status(self): 'POST', 'http://foo', body=p.encode(), - headers={'Content-Type': 'application/octet-stream'}, + headers={'Content-Type': 'text/plain'}, timeout=5, ) assert c.state == 'disconnected' diff --git a/tests/common/test_client.py b/tests/common/test_client.py index 16e66900..c9132044 100644 --- a/tests/common/test_client.py +++ b/tests/common/test_client.py @@ -1466,7 +1466,7 @@ def test_write_loop_polling_one_packet(self): 'POST', 'http://foo', body=p.encode(), - headers={'Content-Type': 'application/octet-stream'}, + headers={'Content-Type': 'text/plain'}, timeout=5, ) @@ -1501,7 +1501,7 @@ def test_write_loop_polling_three_packets(self): 'POST', 'http://foo', body=p.encode(), - headers={'Content-Type': 'application/octet-stream'}, + headers={'Content-Type': 'text/plain'}, timeout=5, ) @@ -1534,7 +1534,7 @@ def test_write_loop_polling_two_packets_done(self): 'POST', 'http://foo', body=p.encode(), - headers={'Content-Type': 'application/octet-stream'}, + headers={'Content-Type': 'text/plain'}, timeout=5, ) assert c.state == 'connected' @@ -1563,7 +1563,7 @@ def test_write_loop_polling_bad_connection(self): 'POST', 'http://foo', body=p.encode(), - headers={'Content-Type': 'application/octet-stream'}, + headers={'Content-Type': 'text/plain'}, timeout=5, ) assert c.state == 'connected' @@ -1592,7 +1592,7 @@ def test_write_loop_polling_bad_status(self): 'POST', 'http://foo', body=p.encode(), - headers={'Content-Type': 'application/octet-stream'}, + headers={'Content-Type': 'text/plain'}, timeout=5, ) assert c.state == 'disconnected'