Skip to content

Commit

Permalink
imap - use write_raw in write_string_literal
Browse files Browse the repository at this point in the history
avoids splitting the length identifier in multiple packets
required by Exchange …
  • Loading branch information
commonism authored and jgosmann committed Jun 30, 2023
1 parent d9715b0 commit aea3150
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions dmarc_metrics_exporter/imap_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,10 @@ async def write_int(self, num: int):
async def write_string_literal(self, string: str):
encoded = string.encode("utf-8")
self._server_ready.clear()
self.writer.write(b"{")
self.writer.write(str(len(encoded)).encode("ascii"))
self.writer.write(b"}\r\n")
await self._drain()
await self.write_raw(b"{" + str(len(encoded)).encode("ascii") + b"}\r\n")
await self._server_ready.wait()

self.writer.write(encoded)
await self._drain()
await self.write_raw(encoded)


class _CommandsInUse:
Expand Down

0 comments on commit aea3150

Please sign in to comment.