发信人: kenmlee() 
整理人: kenmlee(2000-07-08 16:49:34), 站内信件
 | 
 
 
8 Connections
 
 #8 连接 /#
 
 8.1 Persistent Connections
 
 #8.1 永久连接 /#
 
 8.1.1 Purpose
 
 #8.1.1 目的 /#
 
    Prior to persistent connections, a separate TCP connection was
    established to fetch each URL, increasing the load on HTTP servers
  
    and causing congestion on the Internet. The use of inline images an 
 d
    other associated data often requires a client to make multiple
    requests of the same server in a short amount of time. Analyses of
  
    these performance problems are available [30][27]; analysis and
    results from a prototype implementation are in [26].
 
 #  在使用永久连接以前,每个URL的获取是通过分别建立TCP连接实现的,既加重 
 了
    HTTP服务器的负载又使Internet更加拥挤。内嵌图片的使用和其他关联数据经 
 常
    要求客户程序在短时间内对同一个服务器进行多次请求。这些执行问题的分析 
 见
    [30][27],一个原型实现的分析和结果见[26]。
 /#
 
    Persistent HTTP connections have a number of advantages:
 
      o  By opening and closing fewer TCP connections, CPU time is save 
 d,
         and memory used for TCP protocol control blocks is also saved. 
 
      o  HTTP requests and responses can be pipelined on a connection.
  
         Pipelining allows a client to make multiple requests without
         waiting for each response, allowing a single TCP connection to 
  be
         used much more efficiently, with much lower elapsed time.
      o  Network congestion is reduced by reducing the number of packet 
 s
         caused by TCP opens, and by allowing TCP sufficient time to
         determine the congestion state of the network.
      o  HTTP can evolve more gracefully; since errors can be reported
  
         without the penalty of closing the TCP connection. Clients usi 
 ng
         future versions of HTTP might optimistically try a new feature 
 , but
         if communicating with an older server, retry with old semantic 
 s
         after an error is reported.
 
 #  永久HTTP连接有如下优点:
 
      o  通过减少打开和关闭更少的TCP连接,节约了CPU时间和用于TCP协议控制 
 块的内存。
      o  一个连接中的HTTP请求和响应可以管道化,管道允许客户程序发出多个 
 请求而无需
         等待每个响应,使单个TCP连接可以更加有效的使用,并且减少了公用的 
 时间。
      o  减少了TCP连接的打开就减少了数据包的数量,于是减少了网络拥塞,并 
 且使TCP有
         充分的时间来判断网络的拥塞状态。
      o  HTTP本身可以得到更好的发展,因为错误报告无需强制关闭TCP连接。客 
 户应用程序
         在使用将来新版本的HTTP时可能通过使用新的特征来优化,但如果和一 
 个旧的服务器
 	通讯,当错误发生时使用旧的语法重试。
 /#
 
    HTTP implementations SHOULD implement persistent connections.
 
 #  HTTP的实现应该实现永久连接。 /#
 
 8.1.2 Overall Operation
 
 #8.1.2 总体运作机制 /#
 
    A significant difference between HTTP/1.1 and earlier versions of
    HTTP is that persistent connections are the default behavior of any 
 
    HTTP connection. That is, unless otherwise indicated, the client ma 
 y
    assume that the server will maintain a persistent connection.
 
 #  HTTP/1.1和以前版本的HTTP之间的一个显著的不同是,永久连接是HTTP的缺省 
 连接。
    也就是说,除非专门指出,客户程序可以假设服务器将维护一个永久连接。
  
 /#
 
    Persistent connections provide a mechanism by which a client and a
  
    server can signal the close of a TCP connection. This signaling tak 
 es
    place using the Connection header field. Once a close has been
    signaled, the client MUST not send any more requests on that
    connection.
 
 #  永久连接提供客户程序和服务器程序的TCP连接关闭信号机制,这个信号通过 
 连接头域
    (Connection)传递。一旦收到关闭信号,客户程序必须不再通过这个连接发 
 送任何
    请求。
 /#
 
 8.1.2.1 Negotiation
 
 #8.1.2.1 协商 /#
 
    An HTTP/1.1 server MAY assume that a HTTP/1.1 client intends to
    maintain a persistent connection unless a Connection header includi 
 ng
    the connection-token "close" was sent in the request. If the server 
 
    chooses to close the connection immediately after sending the
    response, it SHOULD send a Connection header including the
    connection-token close.
 
 #  除非在请求中的连接头域(Connection)包含关闭连接标示“close”,否则 
 HTTP/1.1
    服务器将假设HTTP/1.1的客户程序意图维持一个永久连接。如果服务器选择在 
 发送
    响应后立即关闭连接,它应该发送包含关闭连接标示的连接头域(Connectio 
 n)。
 /#
 
    An HTTP/1.1 client MAY expect a connection to remain open, but woul 
 d
    decide to keep it open based on whether the response from a server
  
    contains a Connection header with the connection-token close. In ca 
 se
    the client does not want to maintain a connection for more than tha 
 t
    request, it SHOULD send a Connection header including the
    connection-token close.
 
 #  HTTP/1.1客户应用可以认为连接是一直打开的,但是是否保持打开状态决定于 
 
    服务器返回的响应中的连接头域(Connection)是否包含连接标示close.一旦
  
    客户应用不想维护这个连接用户其后的请求,它应该发送一个连接(connectio 
 n)
    包含连接标示close的头域.
 /#
 
    If either the client or the server sends the close token in the
    Connection header, that request becomes the last one for the
    connection.
 
 #  如果客户应用或服务器中的任何一个在连接头域(connection)中发送了连接
  
    标示close,这个请求便成了这个连接的最后一个请求.
 /#
 
    Clients and servers SHOULD NOT assume that a persistent connection  
 is
    maintained for HTTP versions less than 1.1 unless it is explicitly
  
    signaled. See section 19.7.1 for more information on backwards
    compatibility with HTTP/1.0 clients.
 
 #  除非显式指出,客户应用和服务器不应该假设在低于HTTP/1.1版本中将要维护 
 
    一个永久连接.见第19.7.1节关于和HTTP/1.0的客户应用的向后兼容信息.
 /#
 
    In order to remain persistent, all messages on the connection must
  
    have a self-defined message length (i.e., one not defined by closur 
 e
    of the connection), as described in section 4.4.
 
 #  为了维护永久连接,所有在连接上的信息必须有一个自定义的消息长度(例如: 
 
    一个为定义的出现,连接将关闭),如第4.4节描述的.
 /#
 
 
 -- ※ 修改:.kenmlee 于 Jul  8 16:38:10 修改本文.[FROM: 61.140.188.222] ※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 61.140.188.222]
  | 
 
 
 |