问题描述
我通过Lambda集成设置了API网关,并遇到了这个问题.
I set up API gateway with Lambda Integration and came across this problem.
请求URI:https://api-gateway-host/stage/hoge
hoge不是配置的路径,因此返回:
hoge is not a configured path so this returned:
请求URI:https://api-gateway-host/stage/ho[ge
路径为ho"[" ge.它也不是配置的路径,所以我希望得到相同的结果,但是:
The path is ho"["ge. It's also not a configured path so I expected same result but:
所有/ho]ge
,/ho[]ge
,/ho[g]e
,/hoge[]
和/hoge[1]
都返回相同的结果.实际上,如果方括号在/hoge?q=hoge[]
之类的查询"中,则可以接受.
All of /ho]ge
, /ho[]ge
, /ho[g]e
, /hoge[]
and /hoge[1]
return the same result.Actually if square brackets are in "query" like /hoge?q=hoge[]
, it can be accepted.
有人知道原因吗?它是Api网关的限制吗?我认为它没有违反RFC.
Does anyone know the reason? Is it a Api gateway's limitation?I think it doesn't violate RFC.
环境
- AWS us-east-1
- 带有空lambda函数的Lambda代理的基本设置
- 无请求验证(我启用了请求验证,但结果相同)
- 浏览器是Google Chrome浏览器(与Curl相同)
推荐答案
实际上,API网关URL中不允许使用方括号.这是服务的限制,并且不与RFC标准保持一致.
Actually, square brackets are not allowed in an API gateway URL. This is a limitation of the service and does not align with RFC standards.
- 请参阅此AWS线程,其中将在2016年讨论此限制.
- 仅从本月(八月)开始,参见此AWS未回答的问题 2018)再次询问何时将支持方括号.
- See this AWS thread which discusses this limitation in 2016.
- See this AWS unanswered question from just this month (Aug 2018) that again asks when square brackets will be supported.
要解决此限制,您可以对方括号进行编码,如中的详细说明此线程.
To get around this limitation, you can encode square brackets, as detailed in this thread.
这篇关于当方括号("[",“]")在路径中时,AWS API网关返回400错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!