Skip to content

Commit 6bb0904

Browse files
authored
chore(middleware-expect-continue): do not set expect header if using FetchHttpHandler (#6046)
1 parent 3179af2 commit 6bb0904

File tree

1 file changed

+9
-5
lines changed
  • packages/middleware-expect-continue/src

1 file changed

+9
-5
lines changed

packages/middleware-expect-continue/src/index.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HttpRequest } from "@smithy/protocol-http";
1+
import { HttpHandler, HttpRequest } from "@smithy/protocol-http";
22
import {
33
BuildHandler,
44
BuildHandlerArguments,
@@ -7,21 +7,25 @@ import {
77
BuildMiddleware,
88
MetadataBearer,
99
Pluggable,
10+
RequestHandler,
1011
} from "@smithy/types";
1112

1213
interface PreviouslyResolved {
1314
runtime: string;
15+
requestHandler?: RequestHandler<any, any, any> | HttpHandler<any>;
1416
}
1517

1618
export function addExpectContinueMiddleware(options: PreviouslyResolved): BuildMiddleware<any, any> {
1719
return <Output extends MetadataBearer>(next: BuildHandler<any, Output>): BuildHandler<any, Output> =>
1820
async (args: BuildHandlerArguments<any>): Promise<BuildHandlerOutput<Output>> => {
1921
const { request } = args;
2022
if (HttpRequest.isInstance(request) && request.body && options.runtime === "node") {
21-
request.headers = {
22-
...request.headers,
23-
Expect: "100-continue",
24-
};
23+
if (options.requestHandler?.constructor?.name !== "FetchHttpHandler") {
24+
request.headers = {
25+
...request.headers,
26+
Expect: "100-continue",
27+
};
28+
}
2529
}
2630
return next({
2731
...args,

0 commit comments

Comments
 (0)