@@ -3932,7 +3932,7 @@ module.exports = function(module) {
3932
3932
/*! exports provided: name, version, description, main, types, scripts, repository, keywords, author, license, bugs, homepage, dependencies, devDependencies, default */
3933
3933
/***/ ( function ( module ) {
3934
3934
3935
- module . exports = JSON . parse ( "{\"name\":\"cos-js-sdk-v5\",\"version\":\"1.9.0-beta.1\",\"description\":\"JavaScript SDK for [腾讯云对象存储](https://cloud.tencent.com/product/cos)\",\"main\":\"dist/cos-js-sdk-v5.js\",\"types\":\"index.d.ts\",\"scripts\":{\"prettier\":\"prettier --write src demo/demo.js demo/CIDemos/*.js test/test.js server/sts.js lib/request.js index.d.ts\",\"server\":\"node server/sts.js\",\"dev\":\"cross-env NODE_ENV=development webpack -w --mode=development\",\"build\":\"cross-env NODE_ENV=production webpack --mode=production\",\"cos-auth.min.js\":\"uglifyjs ./demo/common/cos-auth.js -o ./demo/common/cos-auth.min.js -c -m\",\"test\":\"jest --runInBand --coverage\",\"postinstall\":\"patch-package\"},\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/tencentyun/cos-js-sdk-v5.git\"},\"keywords\":[],\"author\":\"carsonxu\",\"license\":\"ISC\",\"bugs\":{\"url\":\"https://github.com/tencentyun/cos-js-sdk-v5/issues\"},\"homepage\":\"https://github.com/tencentyun/cos-js-sdk-v5#readme\",\"dependencies\":{\"fast-xml-parser\":\"4.5.0\"},\"devDependencies\":{\"@babel/core\":\"7.17.9\",\"@babel/plugin-transform-runtime\":\"7.18.10\",\"@babel/preset-env\":\"7.16.11\",\"babel-loader\":\"8.2.5\",\"body-parser\":\"^1.18.3\",\"cross-env\":\"^5.2.0\",\"express\":\"^4.16.4\",\"jest\":\"29.7.0\",\"jest-environment-jsdom\":\"29.7.0\",\"patch-package\":\"^8.0.0\",\"prettier\":\"^3.0.1\",\"qcloud-cos-sts\":\"^3.0.2\",\"request\":\"^2.87.0\",\"terser-webpack-plugin\":\"4.2.3\",\"uglifyjs\":\"^2.4.11\",\"webpack\":\"4.46.0\",\"webpack-cli\":\"4.10.0\"}}" ) ;
3935
+ module . exports = JSON . parse ( "{\"name\":\"cos-js-sdk-v5\",\"version\":\"1.9.0\",\"description\":\"JavaScript SDK for [腾讯云对象存储](https://cloud.tencent.com/product/cos)\",\"main\":\"dist/cos-js-sdk-v5.js\",\"types\":\"index.d.ts\",\"scripts\":{\"prettier\":\"prettier --write src demo/demo.js demo/CIDemos/*.js test/test.js server/sts.js lib/request.js index.d.ts\",\"server\":\"node server/sts.js\",\"dev\":\"cross-env NODE_ENV=development webpack -w --mode=development\",\"build\":\"cross-env NODE_ENV=production webpack --mode=production\",\"cos-auth.min.js\":\"uglifyjs ./demo/common/cos-auth.js -o ./demo/common/cos-auth.min.js -c -m\",\"test\":\"jest --runInBand --coverage\",\"postinstall\":\"patch-package\"},\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/tencentyun/cos-js-sdk-v5.git\"},\"keywords\":[],\"author\":\"carsonxu\",\"license\":\"ISC\",\"bugs\":{\"url\":\"https://github.com/tencentyun/cos-js-sdk-v5/issues\"},\"homepage\":\"https://github.com/tencentyun/cos-js-sdk-v5#readme\",\"dependencies\":{\"fast-xml-parser\":\"4.5.0\"},\"devDependencies\":{\"@babel/core\":\"7.17.9\",\"@babel/plugin-transform-runtime\":\"7.18.10\",\"@babel/preset-env\":\"7.16.11\",\"babel-loader\":\"8.2.5\",\"body-parser\":\"^1.18.3\",\"cross-env\":\"^5.2.0\",\"express\":\"^4.16.4\",\"jest\":\"29.7.0\",\"jest-environment-jsdom\":\"29.7.0\",\"patch-package\":\"^8.0.0\",\"prettier\":\"^3.0.1\",\"qcloud-cos-sts\":\"^3.0.2\",\"request\":\"^2.87.0\",\"terser-webpack-plugin\":\"4.2.3\",\"uglifyjs\":\"^2.4.11\",\"webpack\":\"4.46.0\",\"webpack-cli\":\"4.10.0\"}}" ) ;
3936
3936
3937
3937
/***/ } ) ,
3938
3938
@@ -8761,9 +8761,7 @@ function getAuthorizationAsync(params, callback) {
8761
8761
var headers = util . clone ( params . Headers ) ;
8762
8762
var headerHost = '' ;
8763
8763
util . each ( headers , function ( v , k ) {
8764
- if ( v === '' ) {
8765
- delete headers [ k ] ;
8766
- }
8764
+ ( v === '' || [ 'content-type' , 'cache-control' , 'expires' ] . indexOf ( k . toLowerCase ( ) ) > - 1 ) && delete headers [ k ] ;
8767
8765
if ( k . toLowerCase ( ) === 'host' ) headerHost = v ;
8768
8766
} ) ;
8769
8767
// ForceSignHost明确传入false才不加入host签名
@@ -9054,41 +9052,6 @@ function submitRequest(params, callback) {
9054
9052
params . qs && ( params . qs = util . clearKey ( params . qs ) ) ;
9055
9053
var Query = util . clone ( params . qs ) ;
9056
9054
params . action && ( Query [ params . action ] = '' ) ;
9057
- var contentType ;
9058
- var contentLength = 0 ;
9059
- // 指定一个默认的 content-type,如不指定浏览器默认会指定 text/plain;charset=UTF-8
9060
- var defaultContentType = 'text/plain' ;
9061
- util . each ( params . headers , function ( value , key ) {
9062
- if ( key . toLowerCase ( ) === 'content-type' ) {
9063
- contentType = value ;
9064
- }
9065
- if ( key . toLowerCase ( ) === 'content-length' ) {
9066
- contentLength = value ;
9067
- }
9068
- } ) ;
9069
- var method = params . method . toLowerCase ( ) ;
9070
- var body = params . body ;
9071
- if ( body ) {
9072
- if ( ! contentLength ) {
9073
- // 传了请求体需补充 content-length
9074
- var size = util . getContentLength ( body ) ;
9075
- if ( size === null ) {
9076
- callback ( util . error ( new Error ( 'params body format error, Only allow File|Blob|String.' ) ) ) ;
9077
- return ;
9078
- }
9079
- params . headers [ 'Content-Length' ] = size ;
9080
- }
9081
- } else {
9082
- // 非 get、head 请求的空请求体需补充 content-length = 0
9083
- var noContentLengthMethods = [ 'get' , 'head' ] . includes ( method ) ;
9084
- if ( ! noContentLengthMethods ) {
9085
- params . headers [ 'Content-Length' ] = 0 ;
9086
- }
9087
- }
9088
- // 补充默认 content-type,(putObject/multipartInit 不需要补充)
9089
- if ( contentType === undefined ) {
9090
- params . headers [ 'Content-Type' ] = defaultContentType ;
9091
- }
9092
9055
9093
9056
/**
9094
9057
* 手动传params.SignHost的场景:cos.getService、cos.getObjectUrl
@@ -10583,7 +10546,7 @@ var obj2str = function obj2str(obj, lowerCaseKey) {
10583
10546
} ;
10584
10547
10585
10548
// 可以签入签名的headers
10586
- var signHeaders = [ 'cache-control' , 'content-disposition' , 'content-encoding' , 'content-length' , 'content-md5' , 'content-type' , ' expect', 'expires' , 'host' , 'if-match' , 'if-modified-since' , 'if-none-match' , 'if-unmodified-since' , 'origin' , 'range' , 'transfer-encoding' , 'pic-operations' ] ;
10549
+ var signHeaders = [ 'cache-control' , 'content-disposition' , 'content-encoding' , 'content-length' , 'content-md5' , 'expect' , 'expires' , 'host' , 'if-match' , 'if-modified-since' , 'if-none-match' , 'if-unmodified-since' , 'origin' , 'range' , 'transfer-encoding' , 'pic-operations' ] ;
10587
10550
var getSignHeaderObj = function getSignHeaderObj ( headers ) {
10588
10551
var signHeaderObj = { } ;
10589
10552
for ( var i in headers ) {
@@ -11223,24 +11186,6 @@ var getFileSize = function getFileSize(api, params, callback) {
11223
11186
params . ContentLength = size ;
11224
11187
callback ( null , size ) ;
11225
11188
} ;
11226
- var getContentLength = function getContentLength ( body ) {
11227
- var size = null ;
11228
- var haveSize = body instanceof Blob || body . toString ( ) === '[object File]' || body . toString ( ) === '[object Blob]' ;
11229
- if ( typeof body === 'string' ) {
11230
- var f = new Blob ( [ body ] , {
11231
- type : 'text/plain'
11232
- } ) ;
11233
- size = f . size ;
11234
- f = null ;
11235
- } else if ( body instanceof ArrayBuffer ) {
11236
- var f = new Blob ( [ body ] ) ;
11237
- size = f . size ;
11238
- f = null ;
11239
- } else if ( haveSize ) {
11240
- size = body . size ;
11241
- }
11242
- return size ;
11243
- } ;
11244
11189
11245
11190
// 获取调正的时间戳
11246
11191
var getSkewTime = function getSkewTime ( offset ) {
@@ -11396,7 +11341,6 @@ var util = {
11396
11341
camSafeUrlEncode : camSafeUrlEncode ,
11397
11342
throttleOnProgress : throttleOnProgress ,
11398
11343
getFileSize : getFileSize ,
11399
- getContentLength : getContentLength ,
11400
11344
getSkewTime : getSkewTime ,
11401
11345
error : error ,
11402
11346
obj2str : obj2str ,
0 commit comments