Ejemplo n.º 1
0
 public function onHeaders(HeadersEvent $event)
 {
     $response = $event->getResponse();
     // Only works when a Content-Length header is present.
     if (!($size = $response->getHeader('Content-Length'))) {
         return;
     }
     // Wrap the existing body (if present) in a decorator.
     $response->setBody(new DownloadProgressStream($response->getBody() ?: new Stream(fopen('php://temp', 'r+')), $this->downloadProgress, (int) $size, $event->getClient(), $event->getRequest(), $event->getResponse()));
 }
Ejemplo n.º 2
0
 public function testHasValues()
 {
     $c = new Client();
     $r = new Request('GET', '/');
     $t = new Transaction($c, $r);
     $response = new Response(200);
     $t->setResponse($response);
     $e = new HeadersEvent($t);
     $this->assertSame($c, $e->getClient());
     $this->assertSame($r, $e->getRequest());
     $this->assertSame($response, $e->getResponse());
 }