MCPcopy Index your code
hub / github.com/Kong/httpsnippet / getDecompressionMethods

Function getDecompressionMethods

src/targets/csharp/httpclient/client.ts:7–35  ·  view source on GitHub ↗
(allHeaders: Request['allHeaders'])

Source from the content-addressed store, hash-verified

5import { Client } from '../../targets';
6
7const getDecompressionMethods = (allHeaders: Request['allHeaders']) => {
8 let acceptEncodings = getHeader(allHeaders, 'accept-encoding');
9 if (!acceptEncodings) {
10 return []; // no decompression
11 }
12
13 const supportedMethods: Record<string, string> = {
14 gzip: 'DecompressionMethods.GZip',
15 deflate: 'DecompressionMethods.Deflate',
16 };
17
18 const methods: string[] = [];
19 if (typeof acceptEncodings === 'string') {
20 acceptEncodings = [acceptEncodings];
21 }
22 acceptEncodings.forEach(acceptEncoding => {
23 acceptEncoding.split(',').forEach(encoding => {
24 const match = /\s*([^;\s]+)/.exec(encoding);
25 if (match) {
26 const method = supportedMethods[match[1]];
27 if (method) {
28 methods.push(method);
29 }
30 }
31 });
32 });
33
34 return methods;
35};
36
37export const httpclient: Client = {
38 info: {

Callers 1

client.tsFile · 0.85

Calls 1

getHeaderFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…