Skip to content

Use base64 en/decoder from context in bindings #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ private String getStringInputParam(
case HEADER:
// Encode these to base64 if a MediaType is present.
if (target.hasTrait(MediaTypeTrait.ID)) {
return "Buffer.from(" + baseParam + ").toString('base64')";
return "context.base64Encoder(Buffer.from(" + baseParam + "))";
}
default:
return baseParam;
Expand Down Expand Up @@ -2643,7 +2643,7 @@ private String getStringOutputParam(
) {
// Decode these to base64 if a MediaType is present.
if (bindingType == Location.HEADER && target.hasTrait(MediaTypeTrait.ID)) {
dataSource = "Buffer.from(" + dataSource + ", 'base64').toString('ascii')";
dataSource = "Buffer.from(context.base64Decoder(" + dataSource + ")).toString('utf8')";
}

return HttpProtocolGeneratorUtils.getStringOutputParam(
Expand Down