Skip to content

Instantly share code, notes, and snippets.

@mstaack
Created January 25, 2021 22:13
Show Gist options
  • Save mstaack/a4d453df56a32202df3d5bedfc8fecb4 to your computer and use it in GitHub Desktop.
Save mstaack/a4d453df56a32202df3d5bedfc8fecb4 to your computer and use it in GitHub Desktop.
react-proxy
$loop = React\EventLoop\Factory::create();
$server = new React\Http\Server($loop, function (Psr\Http\Message\ServerRequestInterface $request) use ($loop) {
$read = new React\Stream\ReadableResourceStream(fopen('source url', 'rb'), $loop);
$write = new WritableResourceStream(fopen('php://stdout', 'wb+'), $loop);
$read->pipe($write);
// return streamed response?!
});
$socket = new React\Socket\Server(8080, $loop);
$server->listen($socket);
$loop->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment