Skip to content

Make it possible to supply chunk size to transfer() & transmit()#357

Merged
thekid merged 4 commits into
xp-framework:mainfrom
thekid:feature/transmit-chunks
Jun 27, 2026
Merged

Make it possible to supply chunk size to transfer() & transmit()#357
thekid merged 4 commits into
xp-framework:mainfrom
thekid:feature/transmit-chunks

Conversation

@thekid

@thekid thekid commented Feb 15, 2026

Copy link
Copy Markdown
Member

Example:

use io\streams\StreamTransfer;

$s= new StreamTransfer($in, $out);
$size= 0;
foreach ($s->transmit(1024) as $transferred) {
  $size+= $transferred;
  Console::write("\r", $size, ' byte(s) transferred');
}
$s->close();
@thekid

thekid commented Feb 15, 2026

Copy link
Copy Markdown
Member Author

This breaks yielding this inside a web context:

yield from $stream->transmit();

...as the returned numbers are (erroneously) interpreted as delays by the async server before https://github.com/xp-framework/networking/releases/tag/v10.5.1

Comment thread src/main/php/io/streams/StreamTransfer.class.php
@thekid thekid merged commit 337ef8f into xp-framework:main Jun 27, 2026
16 checks passed
@thekid thekid deleted the feature/transmit-chunks branch June 27, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant