Working on the aws lambda by using the aws proxy response but it's not showing the Gzipped response at client side

Viewed 201

I have created the Example Handler with AwsproxyRequest and response.

I am trying to zip this response with gzipping but in browser it is failing. If I have added this same response in nodejs it is working fine.

public class ExampleHandler1 implements RequestHandler<AwsProxyRequest,AwsProxyResponse> {

    @Override
    public AwsProxyResponse handleRequest(AwsProxyRequest input, Context context) {
        AwsProxyResponse response = new AwsProxyResponse(200, Collections.singletonMap("X-Powered-By", "AWS Lambda & serverless"), "Aaytu");
        try {
            HashMap<String, String> headermap = new HashMap<>();
            headermap.put("Content-Encoding", "gzip");
            headermap.put("Content-Type", "text/html");
            String responseString = Base64.getMimeEncoder().encodeToString(GzipCompressor.compress("Hello there..!!!").getBytes());
            AwsProxyResponse retVal = new AwsProxyResponse(200, headermap, responseString);
            retVal.setBase64Encoded(true);
            return retVal;
        } catch (Exception e) {
        }
        return response;
    }
}
0 Answers
Related