Created
January 25, 2021 22:13
-
-
Save mstaack/a4d453df56a32202df3d5bedfc8fecb4 to your computer and use it in GitHub Desktop.
react-proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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