gpt4 book ai didi

http - 我应该拒绝未使用的请求方法吗?

转载 作者:可可西里 更新时间:2023-11-01 16:11:18 26 4
gpt4 key购买 nike

在我的 Zend Framework MVC 应用程序中,我只使用了两种请求方法:GET 和 POST。我想知道如果收到其他请求类型(例如 PUT 或 DELETE),我是否应该检查我的基本 Controller 以抛出异常。

据我所知,有两个方面需要考虑:

  1. 它会提高安全性吗?如果我允许框架响应 PUT、DELETE 等,我是否让潜在的黑客抢先一步?
  2. 它会干扰网站的正常运行吗?例如,搜索引擎机器人是否依赖 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://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

关于http - 我应该拒绝未使用的请求方法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15594282/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com