Simplify Rest response check
This commit is contained in:
parent
6b9f372cd2
commit
dbfca3f6a4
|
@ -16,7 +16,8 @@ class ApiVersion extends Service {
|
|||
*/
|
||||
public function getApiVersion() {
|
||||
$rest = $this->getService( static::API_VERSION);
|
||||
$rest->GET( null, false);
|
||||
$rest->setIsResponseToCheck( false);
|
||||
$rest->GET();
|
||||
|
||||
return $rest->getCurlResponse();
|
||||
}
|
||||
|
|
|
@ -270,7 +270,8 @@ class FileSystemOperation extends Service {
|
|||
*/
|
||||
public function download( $sourceFilePath){
|
||||
$rest = $this->getAuthService( self::API_DOWNLOAD . base64_encode( $sourceFilePath), false, false);
|
||||
$rest->GET( null, false);
|
||||
$rest->setIsResponseToCheck( false);
|
||||
$rest->GET();
|
||||
|
||||
return $rest->getCurlResponse();
|
||||
}
|
||||
|
|
|
@ -89,7 +89,8 @@ class User extends Service {
|
|||
public function getConfigurationFile( $serverName, $login){
|
||||
$service = sprintf( self::API_VPN_USER_CONFIG, $serverName, $login);
|
||||
$rest = $this->getAuthService( $service, false, false);
|
||||
$rest->GET( null, false);
|
||||
$rest->setIsResponseToCheck( false);
|
||||
$rest->GET();
|
||||
|
||||
return $rest->getCurlResponse();
|
||||
}
|
||||
|
|
|
@ -10,16 +10,16 @@ use alphayax;
|
|||
*/
|
||||
class Rest extends alphayax\utils\Rest {
|
||||
|
||||
/** @var bool */
|
||||
protected $isResponseToCheck = true;
|
||||
|
||||
/**
|
||||
* @param null $curlPostData
|
||||
* @param bool $checkResponse
|
||||
* @throws \Exception
|
||||
* @throws \alphayax\freebox\Exception\FreeboxApiException
|
||||
*/
|
||||
public function GET( $curlPostData = null, $checkResponse = true){
|
||||
public function GET( $curlPostData = null){
|
||||
parent::GET( $curlPostData);
|
||||
if( $checkResponse){
|
||||
$this->checkResponse();
|
||||
}
|
||||
$this->checkResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,6 +54,11 @@ class Rest extends alphayax\utils\Rest {
|
|||
$url = $this->curlGetInfo['url'];
|
||||
// echo ">> $request ($url)" . PHP_EOL;
|
||||
|
||||
/// Don't need to go further if the response have not to be checked (binary content, non standard response, ...)
|
||||
if( ! $this->isResponseToCheck){
|
||||
return;
|
||||
}
|
||||
|
||||
if( false === $this->getSuccess()){
|
||||
|
||||
$response = $this->getCurlResponse();
|
||||
|
@ -106,4 +111,11 @@ class Rest extends alphayax\utils\Rest {
|
|||
return boolval( $this->getCurlResponse()['success']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $isResponseToCheck
|
||||
*/
|
||||
public function setIsResponseToCheck( $isResponseToCheck = true){
|
||||
$this->isResponseToCheck = $isResponseToCheck;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ class RestAuth extends Rest {
|
|||
* @param bool $checkResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function GET( $curlPostData = null, $checkResponse = true){
|
||||
public function GET( $curlPostData = null){
|
||||
$this->add_XFbxAppAuth_Header();
|
||||
parent::GET( $curlPostData, $checkResponse);
|
||||
parent::GET( $curlPostData);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue