通过请求标头发送数据与通过请求正文发送数据 [英] Sending data via request header vs sending data via request body

查看:90
本文介绍了通过请求标头发送数据与通过请求正文发送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过请求标头发送数据和通过请求正文发送数据之间有什么区别.在什么情况下,我们必须通过标头/正文发送数据,什么时候不应该通过标头/正文发送数据?

What is the difference between sending data through the request header and sending data through the request body. Under what circumstances, we have to send the data through the header/body and when shouldn't we send the data through header/body ?

推荐答案

通常最好使用元数据头和业务逻辑所用数据的正文.

It is usually a good idea to use the headers for metadata and the body for the data that is used by the business logic.

需要考虑的几点:

1)如果数据是通过HTTP而不是HTTPS发送的,则代理服务器可以修改标头.

1) If the data is sent via HTTP instead of HTTPS, the proxy servers can modify the headers.

2)如果您使用REST协议在微服务之间进行通信,则互操作性可能很重要.大多数API通常不提供添加/修改自定义标头的功能.

2) If you are using the REST protocol for communication among microservices, interoperability could be important. Most APIs usually do not provide the capability to add/modify custom headers.

3)最好在HTTP标头中包含路由器/防火墙使用的数据,并将正文限制为特定于应用程序的信息.

3) It is better to have the data that is used by routers/firewalls in the HTTP header and limit the body to application specific information.

这篇关于通过请求标头发送数据与通过请求正文发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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