Skip to content

Commit f5f42a4

Browse files
committed
use static clone method
1 parent 91544f2 commit f5f42a4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/middleware-apply-body-checksum/src/applyMd5BodyChecksumMiddleware.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const applyMd5BodyChecksumMiddleware =
1717
(options: Md5BodyChecksumResolvedConfig): BuildMiddleware<any, any> =>
1818
<Output extends MetadataBearer>(next: BuildHandler<any, Output>): BuildHandler<any, Output> =>
1919
async (args: BuildHandlerArguments<any>): Promise<BuildHandlerOutput<Output>> => {
20-
let { request } = args;
20+
const { request } = args;
2121
if (HttpRequest.isInstance(request)) {
2222
const { body, headers } = request;
2323
if (!hasHeader("content-md5", headers)) {
@@ -30,18 +30,18 @@ export const applyMd5BodyChecksumMiddleware =
3030
digest = options.streamHasher(options.md5, body);
3131
}
3232

33-
const cloned = request.clone();
33+
const cloned = HttpRequest.clone(request);
3434
cloned.headers = {
3535
...headers,
3636
"content-md5": options.base64Encoder(await digest),
3737
};
38-
request = cloned;
38+
return next({
39+
...args,
40+
request: cloned,
41+
});
3942
}
4043
}
41-
return next({
42-
...args,
43-
request,
44-
});
44+
return next(args);
4545
};
4646

4747
export const applyMd5BodyChecksumMiddlewareOptions: BuildHandlerOptions = {

0 commit comments

Comments
 (0)