generated from Nodarx/template
fix: message streaming
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -56,16 +56,27 @@ final class ProtocolReader
|
||||
}
|
||||
|
||||
if (str_starts_with($raw, '* ')) {
|
||||
$parts = preg_split('/\s+/', substr($raw, 2), 2) ?: [];
|
||||
$label = strtoupper($parts[0] ?? '');
|
||||
// Keep the payload as a slice of the raw response. FETCH payloads can
|
||||
// contain large message literals, so eagerly splitting here would keep
|
||||
// a second full copy alive while the message is parsed.
|
||||
$labelEnd = 2;
|
||||
while (isset($raw[$labelEnd]) && !ctype_space($raw[$labelEnd])) {
|
||||
$labelEnd++;
|
||||
}
|
||||
$label = strtoupper(substr($raw, 2, $labelEnd - 2));
|
||||
$payloadOffset = $labelEnd;
|
||||
while (isset($raw[$payloadOffset]) && ctype_space($raw[$payloadOffset])) {
|
||||
$payloadOffset++;
|
||||
}
|
||||
$this->logger?->debug('IMAP untagged response received: {raw}', [
|
||||
'label' => $label,
|
||||
'raw' => $raw,
|
||||
]);
|
||||
return new UntaggedResponse(
|
||||
$label,
|
||||
$parts[1] ?? '',
|
||||
'',
|
||||
$raw,
|
||||
$payloadOffset,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -181,4 +192,4 @@ final class ProtocolReader
|
||||
|
||||
return $raw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user