Skip to content

Commit 3098206

Browse files
committed
Merge branch 'sign_v4'
2 parents ba8e67b + eca1de2 commit 3098206

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

S3.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,10 +2004,9 @@ private static function __getHash($string)
20042004
* @param string $method
20052005
* @param string $uri
20062006
* @param string $data
2007-
* @param array $parameters
20082007
* @return array $headers
20092008
*/
2010-
public static function __getSignatureV4($aHeaders, $headers, $method='GET', $uri='', $data = '', $parameters=array())
2009+
public static function __getSignatureV4($aHeaders, $headers, $method='GET', $uri='', $data = '')
20112010
{
20122011
$service = 's3';
20132012
$region = S3::getRegion();
@@ -2034,10 +2033,17 @@ public static function __getSignatureV4($aHeaders, $headers, $method='GET', $uri
20342033
// payload
20352034
$payloadHash = isset($amzHeaders['x-amz-content-sha256']) ? $amzHeaders['x-amz-content-sha256'] : hash('sha256', $data);
20362035

2036+
// parameters
2037+
$parameters = array();
2038+
if (strpos($uri, '?')) {
2039+
list ($uri, $query_str) = @explode("?", $uri);
2040+
parse_str($query_str, $parameters);
2041+
}
2042+
20372043
// CanonicalRequests
20382044
$amzRequests[] = $method;
20392045
$amzRequests[] = $uri;
2040-
$amzRequests[] = http_build_query($parameters);
2046+
$amzRequests[] = http_build_query($parameters);
20412047
// add header as string to requests
20422048
foreach ( $amzHeaders as $k => $v ) {
20432049
$amzRequests[] = $k . ':' . $v;
@@ -2392,8 +2398,7 @@ public function getResponse()
23922398
$this->headers,
23932399
$this->verb,
23942400
$this->uri,
2395-
$this->data,
2396-
$this->parameters
2401+
$this->data
23972402
);
23982403
foreach ($amzHeaders as $k => $v) {
23992404
$headers[] = $k .': '. $v;

0 commit comments

Comments
 (0)