|
| 1 | +import { setFeature } from "@smithy/core"; |
1 | 2 | import { HttpRequest } from "@smithy/protocol-http"; |
2 | 3 | import { |
3 | 4 | AbsoluteLocation, |
|
6 | 7 | BuildHandlerOptions, |
7 | 8 | BuildHandlerOutput, |
8 | 9 | BuildMiddleware, |
| 10 | + HandlerExecutionContext, |
9 | 11 | MetadataBearer, |
10 | 12 | } from "@smithy/types"; |
11 | 13 |
|
@@ -39,7 +41,10 @@ export const compressionMiddleware = |
39 | 41 | config: CompressionResolvedConfig & CompressionPreviouslyResolved, |
40 | 42 | middlewareConfig: CompressionMiddlewareConfig |
41 | 43 | ): BuildMiddleware<any, any> => |
42 | | - <Output extends MetadataBearer>(next: BuildHandler<any, Output>): BuildHandler<any, Output> => |
| 44 | + <Output extends MetadataBearer>( |
| 45 | + next: BuildHandler<any, Output>, |
| 46 | + context: HandlerExecutionContext |
| 47 | + ): BuildHandler<any, Output> => |
43 | 48 | async (args: BuildHandlerArguments<any>): Promise<BuildHandlerOutput<Output>> => { |
44 | 49 | if (!HttpRequest.isInstance(args.request)) { |
45 | 50 | return next(args); |
@@ -88,6 +93,10 @@ export const compressionMiddleware = |
88 | 93 | updatedHeaders = { ...headers, "content-encoding": algorithm }; |
89 | 94 | } |
90 | 95 |
|
| 96 | + if (headers["content-encoding"].includes("gzip")) { |
| 97 | + setFeature(context, "GZIP_REQUEST_COMPRESSION", "L"); |
| 98 | + } |
| 99 | + |
91 | 100 | // We've matched on one supported algorithm in the |
92 | 101 | // priority-ordered list, so we're finished. |
93 | 102 | break; |
|
0 commit comments