public function addRequest(Request $Request) { if (!$Request instanceof Request) { return false; } $this->_arRequestList[$Request->_getID(self::_FRIEND_CLASS_LINK)] = $Request; $Request->_connectMultiHandler($this->_curlMulti); $Request->setCaching($this->_bCaching, $this->_bCachingCheckFileSize); if ($this->_timeout > 0) { $Request->setTimeout($this->_timeout); } else { $requestTimeOut = $Request->getTimeout(); if ($requestTimeOut > $this->_timeoutRequestsMax) { $this->_timeoutRequestsMax = $Request->getTimeout(); } } $this->_iRequest++; return true; }
public function testBigFile() { $requestID = 'TestRequest::testBigFile'; $Request = new Request(self::$_urlBigFile, $requestID); $contentExpectedSize = null; while (true) { try { $Request->setCaching(true, true); $Request->setTimeout(1); $Request->download(); } catch (CurlError $e) { $this->assertEquals(CurlError::E_OPERATION_TIMEDOUT, $e->getCode()); $downloadFilePath = $Request->getDownloadFilePath(true); $contentExpectedSize = $Request->getContentExpectedSize(); unset($Request); $this->assertFileExists($downloadFilePath); $Request = new Request(self::$_urlBigFile, $requestID); continue; } $this->assertTrue($Request->isDownloadSuccess(), 'Error: Request::download method must throw Exception or return success'); break; } $fullFilePath = $Request->getDownloadFilePath(true); $fullStatePath = $Request->getDownloadStateFilePath(true); $this->assertFileExists($fullFilePath); // destructor unset($Request); $this->assertFileExists($fullFilePath); $this->assertTrue(unlink($fullFilePath)); $this->assertTrue(unlink($fullStatePath)); }