114114 * @see \Qcloud\Cos\Service::getService()
115115 */
116116class Client extends GuzzleClient {
117- const VERSION = '2.4.2 ' ;
117+ const VERSION = '2.4.3 ' ;
118118
119119 public $ httpClient ;
120120
@@ -133,7 +133,7 @@ public function __construct(array $cosConfig) {
133133 $ this ->cosConfig ['appId ' ] = isset ($ cosConfig ['credentials ' ]['appId ' ]) ? $ cosConfig ['credentials ' ]['appId ' ] : null ;
134134 $ this ->cosConfig ['secretId ' ] = isset ($ cosConfig ['credentials ' ]['secretId ' ]) ? $ cosConfig ['credentials ' ]['secretId ' ] : '' ;
135135 $ this ->cosConfig ['secretKey ' ] = isset ($ cosConfig ['credentials ' ]['secretKey ' ]) ? $ cosConfig ['credentials ' ]['secretKey ' ] : '' ;
136- $ this ->cosConfig ['anonymous ' ] = isset ($ cosConfig ['credentials ' ]['anonymous ' ]) ? $ cosConfig ['anonymous ' ]['anonymous ' ] : false ;
136+ $ this ->cosConfig ['anonymous ' ] = isset ($ cosConfig ['credentials ' ]['anonymous ' ]) ? $ cosConfig ['credentials ' ]['anonymous ' ] : false ;
137137 $ this ->cosConfig ['token ' ] = isset ($ cosConfig ['credentials ' ]['token ' ]) ? $ cosConfig ['credentials ' ]['token ' ] : null ;
138138 $ this ->cosConfig ['timeout ' ] = isset ($ cosConfig ['timeout ' ]) ? $ cosConfig ['timeout ' ] : 3600 ;
139139 $ this ->cosConfig ['connect_timeout ' ] = isset ($ cosConfig ['connect_timeout ' ]) ? $ cosConfig ['connect_timeout ' ] : 3600 ;
@@ -145,6 +145,7 @@ public function __construct(array $cosConfig) {
145145 $ this ->cosConfig ['retry ' ] = isset ($ cosConfig ['retry ' ]) ? $ cosConfig ['retry ' ] : 1 ;
146146 $ this ->cosConfig ['userAgent ' ] = isset ($ cosConfig ['userAgent ' ]) ? $ cosConfig ['userAgent ' ] : 'cos-php-sdk-v5. ' . Client::VERSION ;
147147 $ this ->cosConfig ['pathStyle ' ] = isset ($ cosConfig ['pathStyle ' ]) ? $ cosConfig ['pathStyle ' ] : false ;
148+ $ this ->cosConfig ['signHost ' ] = isset ($ cosConfig ['signHost ' ]) ? $ cosConfig ['signHost ' ] : true ;
148149 $ this ->cosConfig ['allow_redirects ' ] = isset ($ cosConfig ['allow_redirects ' ]) ? $ cosConfig ['allow_redirects ' ] : false ;
149150 $ this ->cosConfig ['allow_accelerate ' ] = isset ($ cosConfig ['allow_accelerate ' ]) ? $ cosConfig ['allow_accelerate ' ] : false ;
150151
@@ -158,15 +159,15 @@ public function __construct(array $cosConfig) {
158159 return $ request ->withHeader ('User-Agent ' , $ this ->cosConfig ['userAgent ' ]);
159160 }));
160161 if ($ this ->cosConfig ['anonymous ' ] != true ) {
161- $ handler ->push ($ this ::handleSignature ($ this ->cosConfig ['secretId ' ], $ this ->cosConfig ['secretKey ' ]));
162+ $ handler ->push ($ this ::handleSignature ($ this ->cosConfig ['secretId ' ], $ this ->cosConfig ['secretKey ' ], $ this -> cosConfig [ ' signHost ' ] ));
162163 }
163164 if ($ this ->cosConfig ['token ' ] != null ) {
164165 $ handler ->push (Middleware::mapRequest (function (RequestInterface $ request ) {
165166 return $ request ->withHeader ('x-cos-security-token ' , $ this ->cosConfig ['token ' ]);
166167 }));
167168 }
168169 $ handler ->push ($ this ::handleErrors ());
169- $ this ->signature = new Signature (trim ($ this ->cosConfig ['secretId ' ]), trim ($ this ->cosConfig ['secretKey ' ]), trim ($ this ->cosConfig ['token ' ]));
170+ $ this ->signature = new Signature (trim ($ this ->cosConfig ['secretId ' ]), trim ($ this ->cosConfig ['secretKey ' ]), $ this -> cosConfig , trim ($ this ->cosConfig ['token ' ] ));
170171 $ area = $ this ->cosConfig ['allow_accelerate ' ] ? 'accelerate ' : $ this ->cosConfig ['region ' ];
171172 $ this ->httpClient = new HttpClient ([
172173 'base_uri ' => $ this ->cosConfig ['schema ' ].'://cos. ' . $ area . '.myqcloud.com/ ' ,
@@ -289,10 +290,6 @@ private function createPresignedUrl(RequestInterface $request, $expires) {
289290 return $ this ->signature ->createPresignedUrl ($ request , $ expires );
290291 }
291292
292- public function getPresignetUrl ($ method , $ args , $ expires = "+30 minutes " ) {
293- return $ this ->getPresignedUrl ($ method , $ args , $ expires );
294- }
295-
296293 public function getPresignedUrl ($ method , $ args , $ expires = "+30 minutes " ) {
297294 $ command = $ this ->getCommand ($ method , $ args );
298295 $ request = $ this ->commandToRequestTransformer ($ command );
@@ -460,9 +457,9 @@ public static function explodeKey($key) {
460457 }
461458
462459
463- public static function handleSignature ($ secretId , $ secretKey ) {
464- return function (callable $ handler ) use ($ secretId , $ secretKey ) {
465- return new SignatureMiddleware ($ handler , $ secretId , $ secretKey );
460+ public static function handleSignature ($ secretId , $ secretKey, $ signHost ) {
461+ return function (callable $ handler ) use ($ secretId , $ secretKey, $ signHost ) {
462+ return new SignatureMiddleware ($ handler , $ secretId , $ secretKey, $ signHost );
466463 };
467464 }
468465
0 commit comments