Skip to content
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

quarkus-amazon-lambda-rest: wrong base64 encoding and unable to add binary type by configuration #18356

Closed
argenstijn opened this issue Jul 2, 2021 · 6 comments · Fixed by #18532
Labels
area/amazon-lambda kind/bug Something isn't working
Milestone

Comments

@argenstijn
Copy link

Describe the bug

Quarkus version: 2.0.0
Environment: AWS ALB -> Quarkus

When downloading binary content from ALB you will receive a HTTP 502.
See also: aws/serverless-java-container#339

In the following class:

https://github.com/quarkusio/quarkus/blob/main/extensions/amazon-lambda-rest/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java

the body is encoded using the MimeEncoder:
responseBuilder.setBody(Base64.getMimeEncoder().encodeToString(baos.toByteArray()));

This should be changed to
responseBuilder.setBody(Base64.getEncoder().encodeToString(baos.toByteArray()));

Don't forget the other way around!

Also it would be very nice to be able to add binary content by a config property.

Now i have to do it myself by using the following code:

    //also base64 encode http application/pdf content
    LambdaContainerHandler.getContainerConfig().addBinaryContentTypes(.........);    
    //default charset should be UTF-8
    LambdaContainerHandler.getContainerConfig().setDefaultContentCharset(StandardCharsets.UTF_8.name());
@argenstijn argenstijn added the kind/bug Something isn't working label Jul 2, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Jul 2, 2021

/cc @matejvasek, @patriot1burke

@patriot1burke
Copy link
Contributor

Ok, i'll include this in my PR i'm working on.

@argenstijn
Copy link
Author

Thanks.
Any idea when this fix will be implemented?

@patriot1burke
Copy link
Contributor

Working on it now.

@patriot1burke
Copy link
Contributor

FYI, I don't think I want a config switch for binary types. I'm just going to not base 64 encode media types of "text", "xml", or "json". Everything else will be encoded.

@argenstijn
Copy link
Author

Fair enough. But then again, the user should eventually decide what he/she want to do with it. Maybe it has it's own custom media types....etc.

@patriot1burke patriot1burke linked a pull request Jul 8, 2021 that will close this issue
@gsmet gsmet added this to the 2.0.2.Final milestone Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/amazon-lambda kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants