Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用aws代理响应处理aws lambda,但它';s在客户端不显示gzip响应_Java_Amazon Web Services_Aws Lambda_Gzip - Fatal编程技术网

Java 使用aws代理响应处理aws lambda,但它';s在客户端不显示gzip响应

Java 使用aws代理响应处理aws lambda,但它';s在客户端不显示gzip响应,java,amazon-web-services,aws-lambda,gzip,Java,Amazon Web Services,Aws Lambda,Gzip,我已经用AwsproxyRequest和response创建了示例处理程序 我试图用gzip压缩这个响应,但在浏览器中失败了。 如果我在nodejs中添加了相同的响应,那么效果很好 public class ExampleHandler1 implements RequestHandler<AwsProxyRequest,AwsProxyResponse> { @Override public AwsProxyResponse handleRequest(AwsPr

我已经用AwsproxyRequest和response创建了示例处理程序

我试图用gzip压缩这个响应,但在浏览器中失败了。 如果我在nodejs中添加了相同的响应,那么效果很好

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;
    }
}
公共类ExampleHandler1实现RequestHandler{
@凌驾
公共AwsProxyResponse HandlerRequest(AwsProxyRequest输入,上下文){
AwsProxyResponse=新的AwsProxyResponse(200,Collections.singletonMap(“X-Powered-By”,“AWS Lambda&serverless”),“Aaytu”);
试一试{
HashMap headermap=新HashMap();
headermap.put(“内容编码”、“gzip”);
headermap.put(“内容类型”、“文本/html”);
字符串responseString=Base64.getMimeEncoder().encodeToString(gzip压缩程序.compress(“你好!!!”).getBytes());
AwsProxyResponse retVal=新的AwsProxyResponse(200,headermap,responseString);
retVal.setBase64Encoded(true);
返回返回;
}捕获(例外e){
}
返回响应;
}
}