• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/document/documenthandler.php
  • Класс: BitrixDiskDocumentDocumentHandler
  • Вызов: DocumentHandler::checkHttpResponse
public function checkHttpResponse(HttpClient $http)
{
	$status = (int)$http->getStatus();

	if($status === 401)
	{
		$this->errorCollection->add(array(
			new Error('Invalid credentials (401)', self::ERROR_CODE_INVALID_CREDENTIALS)
		));
		return false;
	}
	elseif($status === 403)
	{
		$headers = $http->getHeaders();

		$headerAuthenticate = $headers->get('WWW-Authenticate');
		if(is_string($headerAuthenticate) && mb_strpos($headerAuthenticate, 'insufficient') !== false)
		{
			$this->errorCollection->add(array(
				new Error('Insufficient scope (403)', self::ERROR_CODE_INSUFFICIENT_SCOPE)
			));
		}
		else
		{
			$this->errorCollection->add(array(
				new Error("Unknown error ({$status})", self::ERROR_CODE_UNKNOWN)
			));
		}

		return false;
	}
	elseif($status === 404)
	{
		$this->errorCollection->add(array(
			new Error('The resource could not be found (404)', self::ERROR_CODE_NOT_FOUND)
		));
		return false;
	}
	elseif( !($status >= 200 && $status < 300) )
	{
		$this->errorCollection->add(array(
			new Error("Invalid response status code ({$status})", self::ERROR_INVALID_RESPONSE_STATUS)
		));
		return false;
	}

	return true;
}