@@ -10,13 +10,13 @@ const { setRegion } = require('./setRegion');
10
10
const { getReqUrl } = require ( '../client/getReqUrl' ) ;
11
11
12
12
interface Headers {
13
- [ propName : string ] : any
14
- 'x-oss-date' : string ,
15
- 'x-oss-user-agent' ?: string ,
13
+ [ propName : string ] : any ;
14
+ 'x-oss-date' : string ;
15
+ 'x-oss-user-agent' ?: string ;
16
16
}
17
17
18
18
interface ReqParams {
19
- [ propName : string ] : any
19
+ [ propName : string ] : any ;
20
20
}
21
21
22
22
function getHeader ( headers : Headers , name : string ) {
@@ -34,7 +34,7 @@ export function createRequest(this: any, params) {
34
34
date = + new Date ( ) + this . options . amendTimeSkewed ;
35
35
}
36
36
const headers : Headers = {
37
- 'x-oss-date' : dateFormat ( date , ' UTC:ddd, dd mmm yyyy HH:MM:ss \ 'GMT\'' ) ,
37
+ 'x-oss-date' : dateFormat ( date , " UTC:ddd, dd mmm yyyy HH:MM:ss 'GMT'" )
38
38
} ;
39
39
40
40
if ( typeof window !== 'undefined' ) {
@@ -69,10 +69,11 @@ export function createRequest(this: any, params) {
69
69
70
70
if ( params . content ) {
71
71
if ( ! params . disabledMD5 ) {
72
- headers [ 'Content-MD5' ] = crypto
73
- . createHash ( 'md5' )
74
- . update ( Buffer . from ( params . content , 'utf8' ) )
75
- . digest ( 'base64' ) ;
72
+ if ( ! params . headers || ! params . headers [ 'Content-MD5' ] ) {
73
+ headers [ 'Content-MD5' ] = crypto . createHash ( 'md5' ) . update ( Buffer . from ( params . content , 'utf8' ) ) . digest ( 'base64' ) ;
74
+ } else {
75
+ headers [ 'Content-MD5' ] = params . headers [ 'Content-MD5' ] ;
76
+ }
76
77
}
77
78
if ( ! headers [ 'Content-Length' ] ) {
78
79
headers [ 'Content-Length' ] = params . content . length ;
@@ -87,7 +88,13 @@ export function createRequest(this: any, params) {
87
88
}
88
89
89
90
const authResource = this . _getResource ( params ) ;
90
- headers . authorization = this . authorization ( params . method , authResource , params . subres , headers , this . options . headerEncoding ) ;
91
+ headers . authorization = this . authorization (
92
+ params . method ,
93
+ authResource ,
94
+ params . subres ,
95
+ headers ,
96
+ this . options . headerEncoding
97
+ ) ;
91
98
92
99
// const url = this._getReqUrl(params);
93
100
if ( isIP ( this . options . endpoint . hostname ) ) {
0 commit comments