示例#1
0
 /**
  * Sends response to output.
  * @param IRequest   $request
  * @param IResponse  $response
  */
 public function send(IRequest $request, IResponse $response)
 {
     // Set response headers for the file download
     $response->setHeader('Content-Length', $this->stream->getSize());
     $response->setHeader('Content-Type', $this->contentType);
     $response->setHeader('Content-Disposition', 'attachment; filename="' . $this->name . '";');
     while (!$this->stream->eof()) {
         echo $this->stream->read(4000000.0);
     }
     $this->stream->close();
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function close()
 {
     if ($this->stream !== NULL) {
         try {
             if ($this->closeCascade) {
                 $this->stream->close();
             }
         } finally {
             $this->stream = NULL;
         }
     }
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function close($closeStream = false)
 {
     if (self::STATE_FIRST_ELEMENT != ($this->state | self::STATE_FIRST_ELEMENT)) {
         throw new JsonSerializationException('JSON syntax error, unfinished array or object detected', self::ERROR_GENERIC);
     }
     if ($closeStream) {
         $this->stream->close();
     }
 }
 /**
  * @param StreamInterface $stream
  * @return StreamInterface
  */
 private static function wrapBodyStream(StreamInterface $stream)
 {
     $eofStream = false;
     $methods = ['close' => function () use($stream, &$eofStream) {
         $stream->close();
         $eofStream = true;
     }, 'eof' => function () use($stream, &$eofStream) {
         return $eofStream || $stream->eof();
     }];
     //\GuzzleHttp\Stream\FnStream::decorate($stream, $methods);
     return \GuzzleHttp\Psr7\FnStream::decorate($stream, $methods);
 }
 /**
  * {@inheritdoc}
  */
 public function close()
 {
     $this->stream->close();
 }
 /**
  * {@inheritdoc}
  */
 public function close()
 {
     $this->decoratedStream->close();
 }
 public function close()
 {
     return $this->stream->close();
 }
 public function testCloses()
 {
     $this->b->close();
     $this->assertFalse(is_resource($this->c));
 }