PUT,DELETE,HEAD等方法在大多数Web浏览器中可用吗? [英] Are the PUT, DELETE, HEAD, etc methods available in most web browsers?

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

问题描述

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


不幸的是,同一个浏览器不允许我测试HTTP PUT,DELETE, 。


我也听说浏览器只支持GET和POST,其他来源如:





但是,Firefox中的几个快速测试表明,发送 PUT DELETE 请求按预期工作 - XMLHttpRequest 成功完成,请求显示在服务器日志使用正确的方法。有没有一些方面我缺少,如跨浏览器兼容性或非显而易见的限制?

解决方案

HTML表单(最多HTML 4和XHTML 1)只支持 GET POST 作为HTTP请求方法。解决方法是通过使用由服务器读取的隐藏表单字段通过POST隧道传输其他方法,并相应地分派请求。



但是, GET POST PUT (IE,Firefox,Safari,Chrome,Opera)中的XMLHttpRequest实现(即AJAX调用)支持

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

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

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

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 forms (up to HTML version 4 and XHTML 1) 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.

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).

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

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