コード例 #1
0
ファイル: Progress.php プロジェクト: bobozhangshao/HeartCare
 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()));
 }
コード例 #2
0
ファイル: HeadersEventTest.php プロジェクト: hilmysyarif/sic
 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());
 }