是否所有数据都应通过HTTP-POST发送? [英] Should all data be sent by HTTP-POST?

查看:94
本文介绍了是否所有数据都应通过HTTP-POST发送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些jQuery将数据发送到AddComment.php页面。数据是用户ID(可以通过会话获得),项目ID和文本形式下的评论。

I have some jQuery that sends data to a AddComment.php page. The data is a user id (could be gotten through a session), an item id and a comment under text form.

在这种情况下,是否应通过所有数据发送一个帖子?是否有人可能会发现GET和POST混合?

In this case, should all data be sent through a POST? Are there cases where one might find a mix of GET and POST?

推荐答案

请阅读RFC 2616。

Go read RFC 2616.

与GET和POST相关的非常具体的语义对缓存和日志记录有很大的影响。

There are very specific semantics associated with GET and POST which have a big impact on caching and on logging.

如果你的话例如,要添加的数据应该在POST中发送。是否应通过POST或GET变量发送对被评论项目的引用是有争议的。 (您可以使用查询字符串POST到URL,并且任何有能力的Web语言都应该能够区分通过这两种方法发送的相同变量名称)

In the case of your example, the data to be added should be sent in a POST. Whether a reference to the item being commented on should be sent via POST or GET variable is debatable. (you can POST to a URL with a query string and any competent web language should be able to discriminate between the same variable name sent via both methods)

更透明的示例当GET和POST应该混合时,是POST到前端控制器 - 这里相同的路径被各种不同的功能使用(如果你愿意,可以使用网页)。调用的特定功能位由GET操作中的查询指示。如果将选择条件移入POST,则必须满足前端控制器中的两种方案,并且会丢失日志文件中的功能。

A more transparent example of when GET and POST should be mixed is when POSTing to a front-controller - here the same path is used by various different bits of functionality (web pages if you like). The specific bit of functionality being invoked is indicated by the query in a GET operation. If the selection criteria are moved into the POST then you have to cater for both scenarios within the front controller, and you lose resolution of the functionality in the log files.

这篇关于是否所有数据都应通过HTTP-POST发送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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