为什么说HTTP是无状态协议? [英] Why say that HTTP is a stateless protocol?

查看:230
本文介绍了为什么说HTTP是无状态协议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTTP有HTTP Cookie。 Cookie允许服务器跟踪用户状态,连接数,最后连接数等。

HTTP has HTTP Cookies. Cookies allow the server to track the user state, number of connections, last connection, etc.

HTTP具有持久连接(Keep-Alive),可以发送多个请求相同的TCP连接。

HTTP has persistent connections (Keep-Alive), several requests can be send in same TCP Connection.

推荐答案

即使可以通过同一HTTP连接发送多个请求,服务器也不会附加任何特殊含义他们到达同一个插座。这只是一个性能问题,旨在最大限度地减少为每个请求重新建立连接所花费的时间/带宽。

Even though multiple requests can be sent over the same HTTP connection, the server does not attach any special meaning to their arriving over the same socket. That is solely a performance thing, intended to minimize the time/bandwidth that'd otherwise be spent reestablishing a connection for each request.

就HTTP而言,它们是仍然是单独的请求,并且必须包含足够的信息以满足请求。这就是无国籍的本质。如果没有服务器知道的某些共享信息,请求将不会彼此关联,这在大多数情况下是cookie中的会话ID。

As far as HTTP is concerned, they are all still separate requests and must contain enough information on their own to fulfill the request. That is the essence of "statelessness". Requests will not be associated with each other absent some shared info the server knows about, which in most cases is a session ID in a cookie.

这篇关于为什么说HTTP是无状态协议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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