Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions adafruit_esp32spi/adafruit_esp32spi_wsgiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,16 @@ def finish_response(self, result):
response += "{0}: {1}\r\n".format(*header)
response += "\r\n"
self._client_sock.send(response.encode("utf-8"))
for data in result:
if isinstance(data, bytes):
self._client_sock.send(data)
else:
self._client_sock.send(data.encode("utf-8"))
if isinstance(result, bytes): # send whole response if possible (see #174)
self._client_sock.send(result)
elif isinstance(result, str):
self._client_sock.send(result.encode("utf-8"))
else: # fall back to sending byte-by-byte
for data in result:
if isinstance(data, bytes):
self._client_sock.send(data)
else:
self._client_sock.send(data.encode("utf-8"))
gc.collect()
finally:
if self._debug > 2:
Expand Down