Example #1
0
 public static function getEndpoints()
 {
     if (null == self::$endpoints) {
         self::$endpoints = EndpointProvider::getEndpoints();
     }
     return self::$endpoints;
 }
 public function doAction($request, $iSigner = null, $credential = null, $autoRetry = true, $maxRetryNumber = 3)
 {
     /**
      * @var AcsRequest $request
      */
     if (null == $this->iClientProfile && (null == $iSigner || null == $credential || null == $request->getRegionId() || null == $request->getAcceptFormat())) {
         throw new ClientException("No active profile found.", "SDK.InvalidProfile");
     }
     if (null == $iSigner) {
         $iSigner = $this->iClientProfile->getSigner();
     }
     if (null == $credential) {
         $credential = $this->iClientProfile->getCredential();
     }
     $request = $this->prepareRequest($request);
     $domain = EndpointProvider::findProductDomain($request->getRegionId(), $request->getProduct());
     if (null == $domain) {
         throw new ClientException("Can not find endpoint to access.", "SDK.InvalidRegionId");
     }
     $requestUrl = $request->composeUrl($iSigner, $credential, $domain);
     $httpResponse = HttpHelper::curl($requestUrl, $request->getMethod(), $request->getHeaders());
     $retryTimes = 1;
     while (500 <= $httpResponse->getStatus() && $autoRetry && $retryTimes < $maxRetryNumber) {
         $requestUrl = $request->composeUrl($iSigner, $credential, $domain);
         $httpResponse = HttpHelper::curl($requestUrl, null, $request->getHeaders());
         $retryTimes++;
     }
     return $httpResponse;
 }
 public function testFindProductDomain()
 {
     $this->assertEquals("ecs.aliyuncs.com", EndpointProvider::findProductDomain("cn-hangzhou", "Ecs"));
 }