feat: add fetch message size limit

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-09-26 08:43:32 -04:00
parent 681a66862e
commit 025812fe4e
4 changed files with 145 additions and 9 deletions
@@ -84,8 +84,15 @@ final class FetchOptions
return $this->with('BODYSTRUCTURE');
}
public function withBodyText(): self
/**
* @param int|null $limit Maximum number of octets to fetch (partial fetch `<0.limit>`), null for all
*/
public function withBodyText(?int $limit = null): self
{
if ($limit !== null && $limit > 0) {
return $this->with(sprintf('BODY.PEEK[TEXT]<0.%d>', $limit));
}
return $this->with('BODY.PEEK[TEXT]');
}