diff --git a/elasticsearch_async/connection.py b/elasticsearch_async/connection.py index 6d3c912..86fac61 100644 --- a/elasticsearch_async/connection.py +++ b/elasticsearch_async/connection.py @@ -96,7 +96,8 @@ def perform_request(self, method, url, params=None, body=None, timeout=None, ign try: with async_timeout.timeout(timeout or self.timeout, loop=self.loop): response = yield from self.session.request(method, url, data=body, headers=headers) - raw_data = yield from response.text() + raw_data = yield from response.content.read() + raw_data = raw_data.decode('utf-8', errors='surrogatepass') duration = self.loop.time() - start except asyncio.CancelledError: diff --git a/elasticsearch_async/transport.py b/elasticsearch_async/transport.py index f108a3e..12dcdf4 100644 --- a/elasticsearch_async/transport.py +++ b/elasticsearch_async/transport.py @@ -198,7 +198,7 @@ def perform_request(self, method, url, headers=None, params=None, body=None): if body is not None: try: - body = body.encode('utf-8') + body = body.encode('utf-8', 'surrogatepass') except (UnicodeDecodeError, AttributeError): # bytes/str - no need to re-encode pass