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()); } }
public function read($length) { $data = $this->stream->read($length); $this->hash->update($data); if ($this->eof()) { $result = $this->hash->complete(); if ($this->callback) { call_user_func($this->callback, $result); } } return $data; }