http - PUT、DELETE、HEAD 等方法在大多数 Web 浏览器中都可用吗?

标签 http cross-browser browser ajax

我在这里看到了几个问题,比如 How to debug RESTful services ,其中提到:

Unfortunately that same browser won't allow me to test HTTP PUT, DELETE, and to a certain degree even HTTP POST.

我还听说浏览器仅支持 GET 和 POST,来自其他来源,例如:

但是,Firefox 中的一些快速测试显示发送 PUTDELETE 请求按预期工作 - XMLHttpRequest 成功完成,并且该请求以正确的方法显示在服务器日志中。我是否遗漏了某些方面,例如跨浏览器兼容性或不明显的限制?

最佳答案

没有。 HTML 5 spec提及:

The method and formmethod content attributes are enumerated attributes with the following keywords and states:

The keyword get, mapping to the state GET, indicating the HTTP GET method. The GET method should only request and retrieve data and should have no other effect.

The keyword post, mapping to the state POST, indicating the HTTP POST method. The POST method requests that the server accept the submitted form's data to be processed, which may result in an item being added to a database, the creation of a new web page resource, the updating of the existing page, or all of the mentioned outcomes.

The keyword dialog, mapping to the state dialog, indicating that submitting the form is intended to close the dialog box in which the form finds itself, if any, and otherwise not submit.

The invalid value default for these attributes is the GET state

即HTML 表单仅支持 GETPOST 作为 HTTP 请求方法。解决此问题的方法是使用由服务器读取的隐藏表单字段通过 POST 隧道其他方法,并相应地分派(dispatch)请求。

但是,GETPOSTPUTDELETE 受支持XMLHttpRequest(即 AJAX 调用)在所有主要网络浏览器(IE、Firefox、Safari、Chrome、Opera)中的实现。

关于http - PUT、DELETE、HEAD 等方法在大多数 Web 浏览器中都可用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/165779/

相关文章:

http - OSGi 中的 ReSTLet HTTP 问题

javascript - 在 Angular JS 中使用工厂和 http

javascript - 哪些浏览器支持console.log()?

Ubuntu 中的 HTTP 请求

html - 如何告诉浏览器不要提供保存不正确的密码?

http - Ansible:通过 HTTP 安装 tarball

asp.net - 如何增加 ASP.NET HTTP 进程的超时?

javascript - 在 IE 中输入字段不显示光标或无法输入字母

html - & 是否需要在元描述中是 & ?

javascript - 我的网页如何在没有点击事件的情况下仅使用 JavaScript 下载服务器上的文件