@@ -10,13 +10,13 @@ const { setRegion } = require('./setRegion');
1010const { getReqUrl } = require ( '../client/getReqUrl' ) ;
1111
1212interface 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 ;
1616}
1717
1818interface ReqParams {
19- [ propName : string ] : any
19+ [ propName : string ] : any ;
2020}
2121
2222function getHeader ( headers : Headers , name : string ) {
@@ -34,7 +34,7 @@ export function createRequest(this: any, params) {
3434 date = + new Date ( ) + this . options . amendTimeSkewed ;
3535 }
3636 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'" )
3838 } ;
3939
4040 if ( typeof window !== 'undefined' ) {
@@ -69,10 +69,11 @@ export function createRequest(this: any, params) {
6969
7070 if ( params . content ) {
7171 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+ }
7677 }
7778 if ( ! headers [ 'Content-Length' ] ) {
7879 headers [ 'Content-Length' ] = params . content . length ;
@@ -87,7 +88,13 @@ export function createRequest(this: any, params) {
8788 }
8889
8990 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+ ) ;
9198
9299 // const url = this._getReqUrl(params);
93100 if ( isIP ( this . options . endpoint . hostname ) ) {
0 commit comments