/**
* Make a request to Amazon S3
*
* TODO: support bucket.s3.amazon.com style
*
* @param string $method
* @param string $path
* @param array $params
* @param array $headers
* @param string $data
* @return Zend_Http_Response
*/
public function _makeRequest($method, $path='', $params=null, $headers=array(), $data=null)
{
$retry_count = 0;
if (!is_array($headers)) {
$headers = array($headers);
}
$headers['Date'] = gmdate(DATE_RFC1123, time());
$parts = explode('/', $path);
self::addSignature($method, $path, $headers);
$client = self::getHttpClient();
$client->resetParameters();
$client->setHeaders(array('Content-MD5' => null, 'Expect' => null, 'Range' => null));
$endpoint = self::S3_ENDPOINT;
if (count($parts) > 1){
$endpoint = str_replace('http: array_shift($parts);
$client->setUri($endpoint.'/'.implode('/', $parts));
} else {
$client->setUri(self::S3_ENDPOINT.'/'.$path);
}
$client->setHeaders($headers);
if (is_array($params)) {
foreach ($params as $name=>$value) {
$client->setParameterGet($name, $value);
}
}
if (($method == 'PUT') && ($data !== null)) {
if (!isset($headers['Content-type'])) {
$headers['Content-type'] = self::getMimeType($path);
}
$client->setRawData($data, $headers['Content-type']);
}
do {
$retry = false;
$response = $client->request($method);
$response_code = $response->getStatus();
if ($response_code >= 500 && $response_code < 600 && $retry_count <= 5) {
$retry = true;
$retry_count++;
sleep($retry_count / 4 * $retry_count);
}
else if ($response_code == 307) {
}
else if ($response_code == 100) {
}
} while ($retry);
return $response;
}
Assigning to Jon