如何使用AWS API Gateway返回压缩后的内容 [英] How to return gzipped content with AWS API Gateway
问题描述
我们已经开发了一个提供服务器休息服务并支持Accept-Encoding
标头的应用程序,以通过Content-Encoding:gzip
标头值返回压缩的内容.
We have developed an application that offers serveral rest services and supports Accept-Encoding
header to return compressed content through Content-Encoding:gzip
header value.
此应用程序已部署在AWS的ec2实例上,当我们发送设置了Accept-Encoding
值的请求时,响应已正确构建.
This application is deployed on ec2 instances on aws and when we send a request with Accept-Encoding
value set the response is correctly built.
我们想通过使用api网关公开此api,但它仅用于不压缩请求.当我们发送请求压缩内容的请求时,Content-Encoding
标头设置正确,但响应内容已损坏.
We want to expose this api by using api gateway but it is just working for not compressing requests. When we send a request asking for gzipped content the Content-Encoding
header is set correctly but the response content is corrupt.
我们必须在积分响应或方法响应步骤中设置一些特殊的参数或配置吗?
Do we have to set some special parameter or configuration in integration response or method response steps?
致谢.
推荐答案
自2017年12月19日起.AWSAPI Gateway具有编码支持.
Since Dec 19, 2017. AWS API Gateway has encoding support.
创建API后,只需转到设置",然后选择启用内容编码".
After the API is created, just go to Settings and select Content Encoding Enable.
也此处是AWS官方发布的帖子.
Also here is the AWS official release post.
这篇关于如何使用AWS API Gateway返回压缩后的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!