Skip to content

Commit

Permalink
chore(middleware-expect-continue): do not set expect header if using …
Browse files Browse the repository at this point in the history
…FetchHttpHandler
  • Loading branch information
kuhe committed May 1, 2024
1 parent c4fb66d commit 5e8425d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/middleware-expect-continue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ import {

interface PreviouslyResolved {
runtime: string;
requestHandler: any;
}

export function addExpectContinueMiddleware(options: PreviouslyResolved): BuildMiddleware<any, any> {
return <Output extends MetadataBearer>(next: BuildHandler<any, Output>): BuildHandler<any, Output> =>
async (args: BuildHandlerArguments<any>): Promise<BuildHandlerOutput<Output>> => {
const { request } = args;
if (HttpRequest.isInstance(request) && request.body && options.runtime === "node") {
request.headers = {
...request.headers,
Expect: "100-continue",
};
if (options.requestHandler?.constructor?.name !== "FetchHttpHandler") {
request.headers = {
...request.headers,
Expect: "100-continue",
};
}
}
return next({
...args,
Expand Down

0 comments on commit 5e8425d

Please sign in to comment.