在我的 Zend Framework MVC 应用程序中,我只使用了两种请求方法:GET 和 POST。我想知道如果收到其他请求类型(例如 PUT 或 DELETE),我是否应该检查我的基本 Controller 以抛出异常。
据我所知,有两个方面需要考虑:
- 它会提高安全性吗?如果我允许框架响应 PUT、DELETE 等,我是否让潜在的黑客抢先一步?
- 它会干扰网站的正常运行吗?例如,搜索引擎机器人是否依赖 GET 和 POST 以外的请求?
非常感谢您的想法!
最佳答案
正确的响应代码应该是 405 Method Not Allowed
,包括一个 Allow: GET, POST
header 。
10.4.6 405 Method Not Allowed
The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.
关于http - 我应该拒绝未使用的请求方法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15594282/