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

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

问题描述

HTTP具有HTTP Cookie. Cookies使服务器可以跟踪用户状态,连接数,最后连接等.

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

HTTP具有持久连接(保持活动),可以从同一TCP连接发送多个请求.

HTTP has persistent connections (Keep-Alive) where several requests can be sent from the 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天全站免登陆