I understand that \MediaWiki\Rest\StringStream can be used as an argument to \MediaWiki\Rest\Response::setBody. I was guessing that I could use \MediaWiki\Rest\Stream to use an existing stream rather than a string.
$stream = fopen( 'php://memory', 'r+' ); $response->setBody( new Stream( $stream ) ); foreach ( data as $byte ) { fwrite( $stream, $byte ); } fclose( $stream );
but it outputs
Warning: stream_copy_to_stream(): supplied resource is not a valid stream resource in /var/www/html/includes/Rest/Stream.php on line 16
Are there any uses of the Stream class where I can see how it is used correctly?