我已经使用AwsproxyRequest和响应创建了示例处理程序。
我正在尝试使用gzipping压缩此响应,但在浏览器中它失败了。 如果我在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;
}
}