コード例 #1
0
 /**
  * Get data.
  *
  * @throws RuntimeException
  *
  * @return string
  */
 public function getData()
 {
     $offset = $this->stream->tell();
     if (!is_int($offset)) {
         throw new RuntimeException('Unable to get profile data');
     }
     $this->stream->seek(0);
     $data = $this->stream->getContents();
     $this->stream->seek($offset);
     return $data;
 }
コード例 #2
0
 private function matchesHash(CompleteEvent $event, $hash, StreamInterface $body)
 {
     $body->seek(0);
     while (!$body->eof()) {
         $this->hash->update($body->read(16384));
     }
     $result = $this->hash->complete();
     if ($hash !== $result) {
         throw new MessageIntegrityException(sprintf('Message integrity check failure. Expected "%s" but' . ' got "%s"', $hash, $result), $event->getRequest(), $event->getResponse());
     }
 }
コード例 #3
0
ファイル: Utils.php プロジェクト: bobozhangshao/HeartCare
 /**
  * Calculate a hash of a Stream
  *
  * @param StreamInterface $stream    Stream to calculate the hash for
  * @param string          $algo      Hash algorithm (e.g. md5, crc32, etc)
  * @param bool            $rawOutput Whether or not to use raw output
  *
  * @return string Returns the hash of the stream
  * @throws SeekException
  */
 public static function hash(StreamInterface $stream, $algo, $rawOutput = false)
 {
     $pos = $stream->tell();
     if ($pos > 0 && !$stream->seek(0)) {
         throw new SeekException($stream);
     }
     $ctx = hash_init($algo);
     while (!$stream->eof()) {
         hash_update($ctx, $stream->read(1048576));
     }
     $out = hash_final($ctx, (bool) $rawOutput);
     $stream->seek($pos);
     return $out;
 }
コード例 #4
0
 public function seek($offset, $whence = SEEK_SET)
 {
     return $this->stream->seek($offset, $whence);
 }
コード例 #5
0
ファイル: GuzzleHttpStream.php プロジェクト: lamenath/fbp
 /**
  * {@inheritdoc}
  */
 protected function doSeek($offset, $whence)
 {
     return $this->stream->seek($offset, $whence);
 }
コード例 #6
0
ファイル: PsrStream.php プロジェクト: Air-Craft/air-craft-www
 public function rewind()
 {
     $this->stream->seek(0);
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function rewind()
 {
     $this->stream->seek(0);
     $this->moveToNext();
     parent::rewind();
 }
コード例 #8
0
ファイル: GuzzleHttpStream.php プロジェクト: KGalley/whathood
 /**
  * {@inheritdoc}
  */
 protected function doRewind()
 {
     return $this->stream->seek(0);
 }