0

In my use case, API Gateway serves as an HTTP proxy, using default settings following official tutorial.

It's tested working in test console or via curl. But if I access the link in browser or make an AJAX call, I'll get ERR_CONTENT_DECODING_FAILED.

It seems that API Gateway corrupt the content. Related issue.

Is there a way to forbid API Gateway changing my content? I set Content Handling to passthrough, but clearly it's changing my content.

zachguo
  • 6,200
  • 5
  • 30
  • 31
  • You need to use `curl --compressed ...` if you want to try to duplicate the behavior. Without this option, curl won't send `Accept-Encoding: gzip`, and without that, you're unlikely to receive a response that is improperly encoded, since it shouldn't be encoded at all. – Michael - sqlbot Jun 29 '17 at 08:27
  • @Michael - sqlbot Is there a way to forbid APIGW changing my content? I set `Content Handling` to `passthrough`, but clearly it's changing my content. – zachguo Jun 29 '17 at 19:48
  • You may be up against a current design limitation in API Gateway, based on [this answer](https://stackoverflow.com/a/39458711/1695906). A possible workaround may be to add a static integration request header `Accept-Encoding` with value `'identity'`. – Michael - sqlbot Jun 29 '17 at 21:06
  • This fixed my issue perfectly! Can you post it as an anwser? I'll accept. – zachguo Jun 29 '17 at 21:44

1 Answers1

5

Add a static integration request header Accept-Encoding with value 'identity', so that AWS won't tamper your request.

zachguo
  • 6,200
  • 5
  • 30
  • 31
  • 3
    Could you please explain where to add it ? – Facundo Diaz Cobos Oct 08 '19 at 17:18
  • `AWS won't' tamper your request` is it was API Gateway won't tamper the request or origin server/function , where the header should be placed, Answer deserves to be more precise to help more people. – Sagar May 09 '21 at 13:34