• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

为什么说"HTTP是无状态协议"?

用户头像
it1352
帮助1

问题说明

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.

正确答案

#1

即使可以通过同一个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.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfjgjh
系列文章
更多 icon
同类精品
更多 icon
继续加载