/** * Receives data from the server. * * Receives data from the server as a stream. * * @param int $length The number of bytes to receive. * @param FilterCollection $filters A collection of filters to apply to the * stream while receiving. Note that the filters will not be present on * the stream after receiving is done. * @param string $what Descriptive string about what is being * received (used in exception messages). * * @return resource The received content. */ public function receiveStream($length, FilterCollection $filters = null, $what = 'stream data') { if (false === ($previousState = $this->lock(self::DIRECTION_RECEIVE)) && $this->persist) { throw $this->createException('Unable to obtain receiving lock', 9); } try { $result = parent::receiveStream($length, $filters, $what); } catch (E $e) { $this->lock($previousState, true); throw $e; } $this->lock($previousState, true); return $result; }