22
33namespace Clue \React \EventSource ;
44
5- use Clue \React \Buzz \Browser ;
65use Evenement \EventEmitter ;
76use Psr \Http \Message \ResponseInterface ;
87use React \EventLoop \LoopInterface ;
8+ use React \Http \Browser ;
99use React \Stream \ReadableStreamInterface ;
1010
1111/**
2020 * in order to handle async HTTP requests.
2121 *
2222 * ```php
23- * $loop = \ React\EventLoop\Factory::create();
23+ * $loop = React\EventLoop\Factory::create();
2424 *
25- * $es = new \ Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop);
25+ * $es = new Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop);
2626 * ```
2727 *
2828 * If you need custom connector settings (DNS resolution, TLS parameters, timeouts,
2929 * proxy servers etc.), you can explicitly pass a custom instance of the
3030 * [`ConnectorInterface`](https://github.com/reactphp/socket#connectorinterface)
31- * to the [`Browser`](https://github.com/clue/ reactphp-buzz #browser) instance
31+ * to the [`Browser`](https://github.com/reactphp/http #browser) instance
3232 * and pass it as an additional argument to the `EventSource` like this:
3333 *
3434 * ```php
35- * $connector = new \ React\Socket\Connector($loop, array(
35+ * $connector = new React\Socket\Connector($loop, array(
3636 * 'dns' => '127.0.0.1',
3737 * 'tcp' => array(
3838 * 'bindto' => '192.168.10.1:0'
4242 * 'verify_peer_name' => false
4343 * )
4444 * ));
45- * $browser = new \Clue\ React\Buzz \Browser($loop, $connector);
45+ * $browser = new React\Http \Browser($loop, $connector);
4646 *
47- * $es = new \ Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop, $browser);
47+ * $es = new Clue\React\EventSource\EventSource('https://example.com/stream.php', $loop, $browser);
4848 * ```
4949 */
5050class EventSource extends EventEmitter
@@ -88,7 +88,7 @@ public function __construct($url, LoopInterface $loop, Browser $browser = null)
8888 if ($ browser === null ) {
8989 $ browser = new Browser ($ loop );
9090 }
91- $ this ->browser = $ browser ->withOptions ( array ( ' streaming ' => true , ' obeySuccessCode ' => false ) );
91+ $ this ->browser = $ browser ->withRejectErrorResponse ( false );
9292 $ this ->loop = $ loop ;
9393 $ this ->url = $ url ;
9494
@@ -106,7 +106,8 @@ private function request()
106106 $ headers ['Last-Event-ID ' ] = $ this ->lastEventId ;
107107 }
108108
109- $ this ->request = $ this ->browser ->get (
109+ $ this ->request = $ this ->browser ->requestStreaming (
110+ 'GET ' ,
110111 $ this ->url ,
111112 $ headers
112113 );
0 commit comments