冷HTTP请求或热HTTP请求之间的区别? [英] Difference between Cold or Hot http requests?
问题描述
有人可以向我解释两件事吗?
Could somebody explain me two things:
- 冷HTTP请求或热HTTP请求之间的区别?
- 在Angular 2中HTTP请求是冷还是热?
推荐答案
在Angular中,通过Http服务发出的http请求很冷.
In Angular, http requests made from the Http service are cold.
在这种情况下,冷表示在有人订阅从Http.get,Http.post等返回的observable之前,不会发出http请求.此外,对http observable的每次订阅都会导致一个不同的http请求成为被解雇.这是因为,作为一个冷可观察的对象,http的可观察对象负责在订阅时创建其生产者(即Ajax请求),并且每个订阅都将创建一个单独的值的生产者(即独立的Ajax请求).
Cold, in this context, means that the http request is not made until someone subscribes to the observable returned from Http.get, Http.post etc. Also, each subscription to an http observable will cause a different http request to be fired. This is because, as a cold observable, the http observable is responsible for creating its producer (i.e. the Ajax request) on subscription, and each subscription will create a separate producer of values (i.e. separate Ajax requests).
这篇关于冷HTTP请求或热HTTP请求之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!