/** * Returns ObjectStorage CDN URLs. * You will less likely use this method directly from ObjectStorage object. This method is used by ObjectStorage_Abstract object. * * @param array */ public function getCdnUrls(ObjectStorage_Abstract $objectStorageObject) { $authData = $this->getAuthenticationData(); $cdnUrls = array(); $headers = $objectStorageObject->getHeaders(); if (count($headers) == 0 || $objectStorageObject->getContext() != ObjectStorage_Abstract::CONTEXT_CDN) { $authData = $this->getAuthenticationData(); $client = $this->getHttpClient(); $client->setHeaders('X-Auth-Token', $authData->authToken); $client->setHeaders('X-Context', 'cdn'); $client->setMethod('HEAD'); $client->setUri($authData->objectStorageUrl . '/' . rawurlencode(ltrim($objectStorageObject->getPath(), '/'))); $response = $client->request(); if ($this->isAcceptableResponse($response->getStatusCode())) { $objectStorageObject->setResponse($response); } else { throw ObjectStorage_Exception_Http::factory('Failed to retrieve "' . $objectStorageObject->getPath() . '".', $response->getStatusCode()); } } $path = '/' . ltrim($objectStorageObject->getPath(), '/'); foreach ($objectStorageObject->getResponse()->getHeaders() as $key => $val) { if (in_array(strtoupper($key), array('X-CDN-URL', 'X-CDN-STREAM-HTTP-URL', 'X-CDN-STREAM-FLASH-URL', 'X-CDN-CUSTOM-URL', 'X-CDN-CUSTOM-STREAM-HTTP-URL', 'X-CDN-CUSTOM-STREAM-FLASH-URL'))) { $cdnUrls[] = $val; } } return $cdnUrls; }