我可以使用POST方法获取数据,使用GET方法发布数据吗? [英] Can I use POST method to get data and GET method to post data?

查看:704
本文介绍了我可以使用POST方法获取数据,使用GET方法发布数据吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 POST 方法从服务器获取数据吗? GET 方法将数据发布到服务器?

Can I use POST method to get data from the server and GET method to post data to the server?

推荐答案

GET POST 方法用于不同目的。它们的语义和用法在 RFC 7231 中进行了描述,这是HTTP / 1.1协议的参考之一。

GET and POST methods exist for different purposes. Their semantic and use are described in the RFC 7231, one of the references for the HTTP/1.1 protocol.

请参阅以下报价:


4.3.1。 GET

GET 方法请求转移当前所选代表
表示目标资源。 GET 是信息
检索的主要机制,也是几乎所有性能优化的重点。
因此,当人们谈到通过HTTP检索某些可识别信息
时,他们通常是指发出 GET 请求。

The GET method requests transfer of a current selected representation for the target resource. GET is the primary mechanism of information retrieval and the focus of almost all performance optimizations. Hence, when people speak of retrieving some identifiable information via HTTP, they are generally referring to making a GET request.

[...]

GET 请求消息中的有效负载已包含没有定义的语义;
在GET请求上发送有效负载主体可能会导致某些现有的
实现拒绝该请求。

A payload within a GET request message has no defined semantics; sending a payload body on a GET request might cause some existing implementations to reject the request.

GET 请求可缓存; [...]

The response to a GET request is cacheable; [...]






4.3.3。 POST

POST 方法请求目标资源处理
根据资源的
自己的特定语义包含在请求中的表示。例如, POST 用于以下
函数(以及其他函数):

The POST method requests that the target resource process the representation enclosed in the request according to the resource's own specific semantics. For example, POST is used for the following functions (among others):


  • 向数据处理流程提供一个数据块,例如输入HTML
    表格的字段;

  • Providing a block of data, such as the fields entered into an HTML form, to a data-handling process;

在公告栏,新闻组,邮件列表,
博客或类似文章组中发布消息;

Posting a message to a bulletin board, newsgroup, mailing list, blog, or similar group of articles;

创建新资源尚未由
原始服务器识别;和

Creating a new resource that has yet to be identified by the origin server; and

将数据附加到资源的现有表示中。

Appending data to a resource's existing representation(s).

[...]

回复 POST 请求只有在包含时才可缓存
显式新鲜度信息。但是, POST 缓存没有得到广泛实施。

Responses to POST requests are only cacheable when they include explicit freshness information. However, POST caching is not widely implemented.

这篇关于我可以使用POST方法获取数据,使用GET方法发布数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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