From 2db8b0b9fc940dfe332dfdf3e778b23d5383adf6 Mon Sep 17 00:00:00 2001 From: djmaze Date: Fri, 19 Nov 2021 13:07:08 +0100 Subject: [PATCH] Added draft code for raw passthru responses To create a JavaScript based IMAP reponse parser --- .../app/libraries/MailSo/Imap/ImapClient.php | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php index 7ed503d0a..324325c1c 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php @@ -531,7 +531,28 @@ class ImapClient extends \MailSo\Net\NetClient $aParameters[] = $aReturnParams; } - $aReturn = $this->SendRequestGetResponse($sCmd, $aParameters)->getFoldersResult($sCmd); + $this->SendRequest($sCommand, $aParams); + $bPassthru = false; + if ($bPassthru) { + // TODO: passthru to parse response in JavaScript + // This will reduce CPU time on server and moves it to the client + // And can be used with the new JavaScript AbstractFetchRemote.streamPerLine(fCallback, sGetAdd) + if (\is_resource($this->ConnectionResource())) { + \SnappyMail\HTTP\Stream::start(); + $sEndTag = $this->getCurrentTag(); + $sLine = \fgets($this->ConnectionResource()); + do { + echo $sLine; + if (0 === \strpos($sLine, $sEndTag)) { + break; + } + $sLine = \fgets($this->ConnectionResource()); + } while (\strlen($sLine)); + exit; + } + } else { + $aReturn = $this->getResponse($sCmd, $aParameters)->getFoldersResult($sCmd); + } // RFC 5464 if (!$bIsSubscribeList && $this->IsSupported('METADATA')) {