细粒度休息HTTP动词浏览器支持 [英] Fine Grained rest HTTP verbs browser support

查看:325
本文介绍了细粒度休息HTTP动词浏览器支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关于浏览器如何实际支持休息http动词(尤其是PUT,DELETE)的任何数据。这个问题主要是由许多来源(例如 stackoverflow answer )通知大多数浏览器不支持PUT和DELETE,但不说哪个。



Rails 解决这个问题使用补丁on客户端,并颠倒服务器上的补丁,但我想知道,例如,哪些浏览器不需要这样的hack。

解决方案

p>如有疑问,请询问安妮



http://annevankesteren.nl/2007/10/http-method-support



这是一个几岁,但它提供了一个干净的健康帐单PUT和DELETE,但它也尝试不同的情况下更晦涩的动词,如TRACE和PROPFIND: / p>

Van Kesteren测试了Firefox 3,Opera 9.5和Internet Explorer 7,预发布和发布的组合。 GET和POST按预期工作,并且都支持来自RFC 2616的标准的http方法集。有一些套管问题,所以你应该尽量坚持大写; TRACE和OPTIONS是分别在Firefox和Opera中出现问题的边缘情况。 CONNECT和TRACE和SEARCH是有问题的IE。请记住,这是在2007年写的所以YMMV。



我认为浏览器不支持除GET和POST之外的整个混乱源于HTML规范列表这两个在 HTML < form> 元素


FORM元素指定用于将表单发送到处理代理的HTTP方法。此属性可以有两个值:




  • get:使用HTTPget方法,表单数据集会附加到由操作属性指定的URI(带有问号(?)作为分隔符),并将此新URI发送给处理代理。


  • :使用HTTPpost方法,表单数据集包含在表单的正文中并发送到处理代理。



< blockquote>

这就是为什么浏览器只在HTML中本地支持GET和POST的原因;



当前(2014年1月) XMLHttpRequest规范另一方面明确说明请求方法应允许通过一些例外(CONNECT,TRACE或TRACK),并且RFC2616方法应该uppercased:


\6。如果方法对CONNECT,DELETE,GET,HEAD,OPTIONS,POST,PUT,TRACE或TRACK是一个不区分大小写的匹配,则从范围0x61(ASCII a)到0x7A(ASCII z)中的每个字节减去0x20。 p>

/ p>


EDIT 另一个来源或多或少有相同的结论:XMLHttpRequest支持PUT和DELETE: http://jshirley.vox。 com / library / post / xmlhttprequest-and-rest.html (警告,截至2014年5月的链接已断开)。



>问题是之前问过



EDIT 2007年的Anne van Kesteren的简历HTML和XMLHttpRequest


的添加部分

Is there any data regarding how browsers actually support rest http verbs (especially PUT, DELETE). This question is mostly motivated by the fact that many sources (such as this stackoverflow answer) inform that most browsers don't suport PUT and DELETE but don't say which.

Rails solves this using a patch on the client, and reversing the patch on the server, but I wonder, for instance, which browsers wouldn't need such hack.

解决方案

When in doubt, ask Anne:

http://annevankesteren.nl/2007/10/http-method-support

It's a couple of years old, but it gives a clean bill of health to PUT and DELETE, but it also tries different cases of more obscure verbs like TRACE and PROPFIND:

Van Kesteren tested Firefox 3, Opera 9.5 and Internet Explorer 7, a mix of pre-release and releases. GET and POST worked as expected, and all supported the standard set of http methods from RFC 2616. There are some casing issues, so you should try to stick with uppercase always; TRACE and OPTIONS are edge cases with problems found in Firefox and Opera, respectively. CONNECT and TRACE and SEARCH are problematic for IE. Bear in mind that this was written in 2007 so YMMV.

I think the whole confusion over browsers not supporting other than GET and POST stems from the fact that the HTML specification lists only these two in the HTML <form> element:

The method attribute of the FORM element specifies the HTTP method used to send the form to the processing agent. This attribute may take two values:

  • get: With the HTTP "get" method, the form data set is appended to the URI specified by the action attribute (with a question-mark ("?") as separator) and this new URI is sent to the processing agent.

  • post: With the HTTP "post" method, the form data set is included in the body of the form and sent to the processing agent.

This is the reason why browsers only support GET and POST natively in HTML; since the standard says so.

The current (January 2014) XMLHttpRequest specification on the other hand states explicitly that request methods should be allowed through with some exceptions (CONNECT, TRACE or TRACK), and that RFC2616 methods should be uppercased:

\6. If method is a case-insensitive match for CONNECT, DELETE, GET, HEAD, OPTIONS, POST, PUT, TRACE, or TRACK, subtract 0x20 from each byte in the range 0x61 (ASCII a) to 0x7A (ASCII z).

If it does not match any of the above, it is passed through literally, including in the final request.

EDIT Another source that has come to more or less the same conclusion: That XMLHttpRequest supports PUT and DELETE: http://jshirley.vox.com/library/post/xmlhttprequest-and-rest.html (warning, broken link as of May 2014).

EDIT The question has been asked before of course, but the two year old answers are still valid.

EDIT Short resume of Anne van Kesteren's page from 2007, and added section on HTML vs XMLHttpRequest

这篇关于细粒度休息HTTP动词浏览器支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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