Skip to content

Commit b0337a4

Browse files
authored
feat(repeater): send binary data as base64 on demand (#498)
1 parent 9589f64 commit b0337a4

File tree

9 files changed

+130
-70
lines changed

9 files changed

+130
-70
lines changed

package-lock.json

Lines changed: 31 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
"better-ajv-errors": "^1.2.0",
3636
"chalk": "^4.1.2",
3737
"ci-info": "^3.8.0",
38-
"content-type": "^1.0.4",
38+
"fast-content-type-parse": "^1.1.0",
3939
"find-up": "^5.0.0",
40+
"iconv-lite": "^0.6.3",
4041
"js-yaml": "^4.1.0",
4142
"ms": "^2.1.3",
4243
"reflect-metadata": "^0.1.13",
@@ -60,7 +61,6 @@
6061
"@semantic-release/exec": "^6.0.3",
6162
"@semantic-release/git": "^10.0.1",
6263
"@types/amqplib": "~0.8.2",
63-
"@types/content-type": "^1.1.5",
6464
"@types/har-format": "^1.2.7",
6565
"@types/jest": "^28.1.7",
6666
"@types/js-yaml": "^4.0.2",

src/Handlers/Events/ForwardResponse.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@ export class ForwardResponse implements Event {
1010
public readonly protocol?: Protocol;
1111
public readonly headers?: Record<string, string | string[]>;
1212
public readonly body?: string;
13+
public readonly encoding?: 'base64';
1314

1415
constructor(
1516
protocol: Protocol,
1617
body: string,
1718
headers: Record<string, string | string[]>,
1819
statusCode?: number,
1920
errorCode?: string,
20-
message?: string
21+
message?: string,
22+
encoding?: 'base64'
2123
) {
2224
this.protocol = protocol;
2325
this.body = body;
2426
this.headers = headers;
2527
this.status_code = statusCode;
2628
this.error_code = errorCode;
2729
this.message = message;
30+
this.encoding = encoding;
2831
}
2932
}

src/Handlers/SendRequestHandler.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,24 @@ export class SendRequestHandler
1919
new Request({ ...event, correlationIdRegex: event.correlation_id_regex })
2020
);
2121

22-
const { statusCode, message, errorCode, body, headers, protocol } =
23-
response;
22+
const {
23+
statusCode,
24+
message,
25+
errorCode,
26+
body,
27+
headers,
28+
protocol,
29+
encoding
30+
} = response;
2431

2532
return new ForwardResponse(
2633
protocol,
2734
body,
2835
headers,
2936
statusCode,
3037
errorCode,
31-
message
38+
message,
39+
encoding
3240
);
3341
}
3442
}

src/Repeater/RepeaterServer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export interface RepeaterServerRequestEvent {
1212
headers?: Record<string, string | string[]>;
1313
correlationIdRegex?: string;
1414
body?: string;
15+
encoding?: 'base64';
16+
maxContentSize?: number;
17+
timeout?: number;
1518
}
1619

1720
export type RepeaterServerNetworkTestEvent =

src/Repeater/ServerRepeaterLauncher.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,24 @@ export class ServerRepeaterLauncher implements RepeaterLauncher {
187187
new Request({ ...event })
188188
);
189189

190-
const { statusCode, message, errorCode, body, headers, protocol } =
191-
response;
190+
const {
191+
statusCode,
192+
message,
193+
errorCode,
194+
body,
195+
headers,
196+
protocol,
197+
encoding
198+
} = response;
192199

193200
return {
194201
protocol,
195202
body,
196203
headers,
197204
statusCode,
198205
errorCode,
199-
message
206+
message,
207+
encoding
200208
};
201209
}
202210
}

0 commit comments

Comments
 (0)