Java 使用aws代理响应处理aws lambda,但它';s在客户端不显示gzip响应
我已经用AwsproxyRequest和response创建了示例处理程序 我试图用gzip压缩这个响应,但在浏览器中失败了。 如果我在nodejs中添加了相同的响应,那么效果很好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
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){
}
返回响应;
}
}