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 testCurl() { $httpResponse = HttpHelper::curl("ecs.aliyuncs.com"); $this->assertEquals(400, $httpResponse->getStatus()); $this->assertNotNull($httpResponse->getBody()); }