大多数 Web 浏览器都提供 PUT、DELETE、HEAD 等方法吗? [英] Are the PUT, DELETE, HEAD, etc methods available in most web browsers?

查看:47
本文介绍了大多数 Web 浏览器都提供 PUT、DELETE、HEAD 等方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里看到了几个问题,例如 如何调试 RESTful 服务,其中提到:

I've seen a couple questions around here like How to debug RESTful services, which mentions:

不幸的是,同一个浏览器不允许我测试 HTTP PUT、DELETE,甚至在某种程度上甚至是 HTTP POST.

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

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

I've also heard that browsers support only GET and POST, from some other sources like:

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

However, a few quick tests in Firefox show that sending PUT and DELETE requests works as expected -- the XMLHttpRequest completes successfully, and the request shows up in the server logs with the right method. Is there some aspect to this I'm missing, such as cross-browser compatibility or non-obvious limitations?

推荐答案

没有.HTML 5 规范 提到:

method和formmethod内容属性为枚举属性使用以下关键字和状态:

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

关键字get,映射到状态GET,表示HTTP GET方法.GET 方法应该只请求和检索数据和应该没有其他影响.

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.

关键字post,映射到状态POST,表示HTTP POST 方式.POST 方法要求服务器接受提交的表单数据进行处理,这可能导致一个项目被添加到数据库中,创建一个新的网络页面资源,现有页面的更新,或所有提到的结果.

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.

关键字dialog,映射到状态对话框,表示提交表单旨在关闭对话框表单发现自己,如果有的话,否则不提交.

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.

这些属性的无效值默认为 GET 状态

The invalid value default for these attributes is the GET state

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

I.e. HTML forms only support GET and POST as HTTP request methods. A workaround for this is to tunnel other methods through POST by using a hidden form field which is read by the server and the request dispatched accordingly.

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

However, GET, POST, PUT and DELETE are supported by the implementations of XMLHttpRequest (i.e. AJAX calls) in all the major web browsers (IE, Firefox, Safari, Chrome, Opera).

这篇关于大多数 Web 浏览器都提供 PUT、DELETE、HEAD 等方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆