You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implementations: Jersey / Spring / Spring Boot / Spark (all)
Scenario
I want to register certain content types as binary so that the AwsProxyHttpServletResponseWriter class will not perform the utf-8 validity scan to see if the data that I'm returning is binary.
I create a pull request: #191 as a strawman for how this might be done.
When you're performing your initial configuration/setup, you can ask the LambdaContainerHandler for its instance of ContainerConfig, and then inform the ContainerConfig about which content types are binary in much the same way that you need to configure them in api-gateway, except that the default setup already configures application/octet-stream and image/(gif|png|jpeg).
Here's a snippet of code that shows how to configure additional binary content types, which is based on the spark initialization code.
private static SparkLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler;
static {
try {
handler = SparkLambdaContainerHandler.getAwsProxyHandler();
LambdaContainerHandler.getContainerConfig().addBinaryContentTypes("application/protobuf");
Routes.create();
Spark.awaitInitialization();
} catch (ContainerInitializationException e) {
// if we fail here. We re-throw the exception to force another cold start
e.printStackTrace();
throw new RuntimeException("Could not initialize Spark container", e);
}
}
Later, when the AwsProxyHttpServletResponseWriter is processing the response, it first checks the configuration to see if the provided content type has been configured as binary, and if it is, then it skips the utf-8 check and immediately treats the response as binary. It still performs the utf-8 conformance check if the content is not configured as binary. As before, once it is determined to be binary, the content is base64 encoded and the base64 encoded flag is set to true.
Expected behavior
n/a This is an enhancement request.
Actual behavior
n/a This is an enhancement request.
Steps to reproduce
n/a This is an enhancement request.
Full log output
n/a
The text was updated successfully, but these errors were encountered:
Scenario
I want to register certain content types as binary so that the
AwsProxyHttpServletResponseWriter
class will not perform the utf-8 validity scan to see if the data that I'm returning is binary.I create a pull request: #191 as a strawman for how this might be done.
When you're performing your initial configuration/setup, you can ask the
LambdaContainerHandler
for its instance ofContainerConfig
, and then inform theContainerConfig
about which content types are binary in much the same way that you need to configure them in api-gateway, except that the default setup already configuresapplication/octet-stream
andimage/(gif|png|jpeg)
.Here's a snippet of code that shows how to configure additional binary content types, which is based on the spark initialization code.
Later, when the
AwsProxyHttpServletResponseWriter
is processing the response, it first checks the configuration to see if the provided content type has been configured as binary, and if it is, then it skips the utf-8 check and immediately treats the response as binary. It still performs the utf-8 conformance check if the content is not configured as binary. As before, once it is determined to be binary, the content is base64 encoded and the base64 encoded flag is set to true.Expected behavior
n/a This is an enhancement request.
Actual behavior
n/a This is an enhancement request.
Steps to reproduce
n/a This is an enhancement request.
Full log output
n/a
The text was updated successfully, but these errors were encountered: