@@ -27,9 +27,8 @@ describe("applyMd5BodyChecksumMiddleware", () => {
27
27
new Uint8Array ( 10 ) ,
28
28
void 0
29
29
] ) {
30
- it ( "should calculate the body hash, encode the result, and set the encoded hash to the provided header" , async ( ) => {
30
+ it ( "should calculate the body hash, encode the result, and set the encoded hash to Content-MD5 header" , async ( ) => {
31
31
const handler = applyMd5BodyChecksumMiddleware ( {
32
- headerName : "checksumHeader" ,
33
32
md5 : MockHash ,
34
33
base64Encoder : mockEncoder ,
35
34
streamHasher : async ( stream : ExoticStream ) => new Uint8Array ( 5 )
@@ -44,13 +43,12 @@ describe("applyMd5BodyChecksumMiddleware", () => {
44
43
45
44
expect ( next . mock . calls . length ) . toBe ( 1 ) ;
46
45
const { request } = next . mock . calls [ 0 ] [ 0 ] ;
47
- expect ( request . headers [ "checksumHeader " ] ) . toBe ( "encoded" ) ;
46
+ expect ( request . headers [ "Content-MD5 " ] ) . toBe ( "encoded" ) ;
48
47
expect ( mockHashUpdate . mock . calls ) . toEqual ( [ [ body || "" ] ] ) ;
49
48
} ) ;
50
49
51
50
it ( "should do nothing if a case-insenitive match for the desired header has already been set" , async ( ) => {
52
51
const handler = applyMd5BodyChecksumMiddleware ( {
53
- headerName : "checksumHeader" ,
54
52
md5 : MockHash ,
55
53
base64Encoder : mockEncoder ,
56
54
streamHasher : async ( stream : ExoticStream ) => new Uint8Array ( 5 )
@@ -61,15 +59,15 @@ describe("applyMd5BodyChecksumMiddleware", () => {
61
59
request : new HttpRequest ( {
62
60
body : body ,
63
61
headers : {
64
- cHeCkSuMhEaDeR : "foo"
62
+ "CoNtEnT-Md5" : "foo"
65
63
}
66
64
} )
67
65
} ) ;
68
66
69
67
expect ( next . mock . calls . length ) . toBe ( 1 ) ;
70
68
const { request } = next . mock . calls [ 0 ] [ 0 ] ;
71
- expect ( request . headers [ "cHeCkSuMhEaDeR " ] ) . toBe ( "foo" ) ;
72
- expect ( request . headers [ "checksumHeader " ] ) . toBe ( undefined ) ;
69
+ expect ( request . headers [ "CoNtEnT-Md5 " ] ) . toBe ( "foo" ) ;
70
+ expect ( request . headers [ "Content-MD5 " ] ) . toBe ( undefined ) ;
73
71
expect ( mockHashUpdate . mock . calls . length ) . toBe ( 0 ) ;
74
72
expect ( mockHashDigest . mock . calls . length ) . toBe ( 0 ) ;
75
73
expect ( mockEncoder . mock . calls . length ) . toBe ( 0 ) ;
@@ -78,7 +76,6 @@ describe("applyMd5BodyChecksumMiddleware", () => {
78
76
79
77
it ( "should use the supplied stream hasher to calculate the hash of a streaming body" , async ( ) => {
80
78
const handler = applyMd5BodyChecksumMiddleware ( {
81
- headerName : "checksumHeader" ,
82
79
md5 : MockHash ,
83
80
base64Encoder : mockEncoder ,
84
81
streamHasher : async ( stream : ExoticStream ) => new Uint8Array ( 5 )
@@ -94,7 +91,7 @@ describe("applyMd5BodyChecksumMiddleware", () => {
94
91
expect ( next . mock . calls . length ) . toBe ( 1 ) ;
95
92
const { request } = next . mock . calls [ 0 ] [ 0 ] ;
96
93
expect ( request . body ) . toStrictEqual ( new ExoticStream ( ) ) ;
97
- expect ( request . headers [ "checksumHeader " ] ) . toBe ( "encoded" ) ;
94
+ expect ( request . headers [ "Content-MD5 " ] ) . toBe ( "encoded" ) ;
98
95
expect ( mockHashDigest . mock . calls . length ) . toBe ( 0 ) ;
99
96
expect ( mockEncoder . mock . calls . length ) . toBe ( 1 ) ;
100
97
expect ( mockEncoder . mock . calls ) . toEqual ( [ [ new Uint8Array ( 5 ) ] ] ) ;
0 commit comments