`
xo_tobacoo
  • 浏览: 384559 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
社区版块
存档分类
最新评论

HTTP1.1协议翻译(转载)

阅读更多
Introduction

1.1 Purpose

   The Hypertext Transfer Protocol (HTTP) is an application-level
   protocol for distributed, collaborative, hypermedia information
   systems. HTTP has been in use by the World-Wide Web global
   information initiative since 1990. The first version of HTTP,
   referred to as HTTP/0.9, was a simple protocol for raw data transfer
   across the Internet. HTTP/1.0, as defined by RFC 1945 [6], improved
   the protocol by allowing messages to be in the format of MIME-like
   messages, containing metainformation about the data transferred and
   modifiers on the request/response semantics. However, HTTP/1.0 does
   not sufficiently take into consideration the effects of hierarchical
   proxies, caching, the need for persistent connections, or virtual
   hosts. In addition, the proliferation of incompletely-implemented
   applications calling themselves "HTTP/1.0" has necessitated a
   protocol version change in order for two communicating applications
   to determine each other's true capabilities.

# 注释 :HTTP 的第1版是 HTTP/0.9 ,它是一个关于通过 Internet 进行原始数据传输简单的协议。

# 而 HTTP/1.0 (也就是 RFC 1945),它允许消息以 MIME-like 的格式传输,包含了数据传输的元信息,

# 对请求/响应消息的语义也进行了修改。但是 HTTP/1.0 对于并没有充分考虑到几个方面的问题,例如

# 分层结构的代理、缓存、永久连接的必要性、虚拟主机(没有 Host: header)。

# 另外大量的还没有完全实现 HTTP/1.0 协议的应用程序都声称自己是使用 HTTP/1.0 标准的,

# 这就导致了急需对原来的协议进行修改,以便两个相互通信的应用程序判断对方的真正支持的协议版本


   This specification defines the protocol referred to as "HTTP/1.1".
   This protocol includes more stringent requirements than HTTP/1.0 in
   order to ensure reliable implementation of its features.


# 注释 :这个声明所定义的协议被称为 HTTP/1.1 ,这个协议包括更多比 HTTP/1.0 更严格的要求,

# 目的是保证协议功能的可靠的实现

   Practical information systems require more functionality than simple
   retrieval, including search, front-end update, and annotation. HTTP
   allows an open-ended set of methods and headers that indicate the
   purpose of a request [47]. It builds on the discipline of reference
   provided by the Uniform Resource Identifier (URI) [3], as a location
   (URL) [4] or name (URN) [20], for indicating the resource to which a





Fielding, et al.            Standards Track                     [Page 7]

RFC 2616                        HTTP/1.1                       June 1999


   method is to be applied. Messages are passed in a format similar to
   that used by Internet mail [9] as defined by the Multipurpose
   Internet Mail Extensions (MIME) [7].

   HTTP is also used as a generic protocol for communication between
   user agents and proxies/gateways to other Internet systems, including
   those supported by the SMTP [16], NNTP [13], FTP [18], Gopher [2],
   and WAIS [10] protocols. In this way, HTTP allows basic hypermedia
   access to resources available from diverse applications.

# 注释 :HTTP 同时也可以作为在用户代理/代理/网关和其他 Internet 系统之间通信的一个通用协议,

# 例如 SMTP、NNTP、FTP、Gopher、WAIS 协议。在这种情况下,HTTP 允许通过不同的应用程序实现

# 对超媒体的基本的访问

1.2 Requirements

   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
   document are to be interpreted as described in RFC 2119 [34].

   An implementation is not compliant if it fails to satisfy one or more
   of the MUST or REQUIRED level requirements for the protocols it
   implements. An implementation that satisfies all the MUST or REQUIRED
   level and all the SHOULD level requirements for its protocols is said
   to be "unconditionally compliant"; one that satisfies all the MUST
   level requirements but not all the SHOULD level requirements for its
   protocols is said to be "conditionally compliant."

1.3 Terminology

   This specification uses a number of terms to refer to the roles
   played by participants in, and objects of, the HTTP communication.

   connection
      A transport layer virtual circuit established between two programs
      for the purpose of communication.

    # 注释 :connection 术语:两个程序出于通信的目的,在双方的传输层建立的虚拟电路

   message
      The basic unit of HTTP communication, consisting of a structured
      sequence of octets matching the syntax defined in section 4 and
      transmitted via the connection.

    # 注释 :message 术语 :HTTP 通信的基本单元,由一个结构化的 octets 序列组成,

    # 该 Octets 序列按照本文第4章所规定的语法排列,并通过上面的 connect 进行传输

   request
      An HTTP request message, as defined in section 5.

    # 注释 :request 术语 :一个 HTTP 请求消息,在第5章会提到

   response
      An HTTP response message, as defined in section 6.

    # 注释 :response 术语 :一个 HTTP 响应消息,在第6章会提到








Fielding, et al.            Standards Track                     [Page 8]

RFC 2616                        HTTP/1.1                       June 1999


   resource
      A network data object or service that can be identified by a URI,
      as defined in section 3.2. Resources may be available in multiple
      representations (e.g. multiple languages, data formats, size, and
      resolutions) or vary in other ways.

    # 注释 :resource 术语 :一个网络数据对象或者服务,它可以已被一个 URI (3.2节)所标识。

    # 一个资源可以以多种表现形式存在(多语言、数据编码、图片质量等)

   entity
      The information transferred as the payload of a request or
      response. An entity consists of metainformation in the form of
      entity-header fields and content in the form of an entity-body, as
      described in section 7.

    # 注释 :entity 术语 :就是指一个请求/响应所传输的实际内容。一个 entity 由元信息组成,

    # 元信息由 header 和 content 组成,具体在第7章提到

   representation
      An entity included with a response that is subject to content
      negotiation, as described in section 12. There may exist multiple
      representations associated with a particular response status.

    # 注释 :representation :它是一个 response ,包含了内容协商

    # 方面的信息,在第12章会提到。一个响应状态可以包含多个 representations

   content negotiation
      The mechanism for selecting the appropriate representation when
      servicing a request, as described in section 12. The
      representation of entities in any response can be negotiated
      (including error responses).

    # 注释 :content negotiation :在处理一个请求时,用于选择合适的 representation 的方法。

    # 任何响应的 entity 的 representation 都可以进行协商(包括发生错误时的响应消息)

   variant
      A resource may have one, or more than one, representation(s)
      associated with it at any given instant. Each of these
      representations is termed a `varriant'.  Use of the term `variant'
      does not necessarily imply that the resource is subject to content
      negotiation.

    # 注释 :variant :一个资源可以有一个或者多个 representations ,每个 representation

    # 就成为一个 variant ,但提到 variant 并不一定就表示和内容协商有关

   client
      A program that establishes connections for the purpose of sending
      requests.

    # 注释 :client :一个程序为了发送一个请求而建立到服务器的连接

   user agent
      The client which initiates a request. These are often browsers,
      editors, spiders (web-traversing robots), or other end user tools.

    # 注释 :user agent 就是指发起一个请求的客户端,一般就是指浏览器、编辑器、网页机器人,

    # 或者其他的用户端工具

   server
      An application program that accepts connections in order to
      service requests by sending back responses. Any given program may
      be capable of being both a client and a server; our use of these
      terms refers only to the role being performed by the program for a
      particular connection, rather than to the program's capabilities
      in general. Likewise, any server may act as an origin server,
      proxy, gateway, or tunnel, switching behavior based on the nature
      of each request.

    # 注释 :server :也是一个程序,用于接受 client 的连接,目的是服务这些请求(返回一个响应)。

    # 任何程序都可以同时扮演 client 和 server 的角色,这里特指“服务”这个特性,

    # 就象其他的服务器一样,任何 server 同时可以扮演 origian server、代理、网关、隧道的角色,

    # 这是基于每个请求的特性进行切换的。





Fielding, et al.            Standards Track                     [Page 9]

RFC 2616                        HTTP/1.1                       June 1999


   origin server
      The server on which a given resource resides or is to be created.

    # 注释 :origin server 术语 :就是请求的对象所在的服务器

   proxy
      An intermediary program which acts as both a server and a client
      for the purpose of making requests on behalf of other clients.
      Requests are serviced internally or by passing them on, with
      possible translation, to other servers. A proxy MUST implement
      both the client and server requirements of this specification. A
      "transparent proxy" is a proxy that does not modify the request or
      response beyond what is required for proxy authentication and
      identification. A "non-transparent proxy" is a proxy that modifies
      the request or response in order to provide some added service to
      the user agent, such as group annotation services, media type
      transformation, protocol reduction, or anonymity filtering. Except
      where either transparent or non-transparent behavior is explicitly
      stated, the HTTP proxy requirements apply to both types of
      proxies.

    # 注释 :proxy 术语 :一个处于中间位置的程序,同时扮演一个服务器和客户机的惧色,

    # 目的是代替其他的客户机来发出请求给真正的服务器。发给代理可能被内部处理后就返回,

    # 或者做一些转换然后在发给真正的服务器。一个代理服务器“必须”实现客户机和服务器

    # 的功能才能被称为一个代理。所谓“透明代理”是一个服务器并不修改请求或者响应,

    # 它只是做代理认证和表示而已。而“非透明代理”是会对请求和响应进行修改的代理,目的是

    # 提供某些附加的服务(相对于 User Agent),例如 group annotation 服务、媒体类型转换、

    # prototcol reduction 、或者 anonymity 过滤。除了需要明确区分“透明代理”和“非透明代理”

    # 这两个概念之外,其他方面的要求对这两种类型的代理都是适用的。


   gateway
      A server which acts as an intermediary for some other server.
      Unlike a proxy, a gateway receives requests as if it were the
      origin server for the requested resource; the requesting client
      may not be aware that it is communicating with a gateway.

    # 注释 :gateway 术语 :扮演一个中间者的角色的服务器,它不象代理,网关就像 origin server

    # 那样接收请求,这点客户机并不知道它所通信的是一个网关,还以为就是真正的服务器

    # 补充 :透明代理和网关不同,前者是从是否修改请求/响应的角度来考虑的,后者是针对是否对客户机

    # 可见的角度来考虑的,平时我们在 IE 中设置的代理肯定不是网关,因为我们可以知道我们在使用代理


   tunnel
      An intermediary program which is acting as a blind relay between
      two connections. Once active, a tunnel is not considered a party
      to the HTTP communication, though the tunnel may have been
      initiated by an HTTP request. The tunnel ceases to exist when both
      ends of the relayed connections are closed.

    # 注释 :tunnerl 属于 :也是一个中间者的角色,在两个连接之间进行透明中继,

    # 一旦激活了隧道,隧道对于 HTTP 通信来说就是“透明的”,仿佛不存在这个环节

    # 一样,虽然这个通道可能是由一个 HTTP 请求初始化的。隧道在通信的双方断开连接

    # 后会自动消失

   



   cache
      A program's local store of response messages and the subsystem
      that controls its message storage, retrieval, and deletion. A
      cache stores cacheable responses in order to reduce the response
      time and network bandwidth consumption on future, equivalent
      requests. Any client or server may include a cache, though a cache
      cannot be used by a server that is acting as a tunnel.

    # 注释 :cache 术语 :一个程序把响应的内容存储在本地,,也包括了对所存储的信息

    # 进行控制(存储、接收、删除)的子系统。Cache 负责存储那些可以被缓存的响应的内容,

    # 目的是减少响应时间,以及减少对网络带宽的使用(减少不必要的请求)。

    # 任何客户机、服务器都可以拥有自己的缓存,但对于扮演一个 tunnel 角色的 server 来说,

    # 它不能使用缓存


   cacheable
      A response is cacheable if a cache is allowed to store a copy of
      the response message for use in answering subsequent requests. The
      rules for determining the cacheability of HTTP responses are
      defined in section 13. Even if a resource is cacheable, there may
      be additional constraints on whether a cache can use the cached
      copy for a particular request.

    # 注释 :cacheable 属于 :如果一个响应允许被存储一份拷贝到缓存中,我们就说它是

    # cacheable 的,在第13章我们会提到如何判断一个响应是否可以被缓存的。

    # 不过即使一个响应是 cacheable 的,对于是否使用缓存中的数据来响应请求也是有一定的规定的



Fielding, et al.            Standards Track                    [Page 10]

RFC 2616                        HTTP/1.1                       June 1999


   first-hand
      A response is first-hand if it comes directly and without
      unnecessary delay from the origin server, perhaps via one or more
      proxies. A response is also first-hand if its validity has just
      been checked directly with the origin server.

    # 注释 :first-hand 术语 :如果一个响应是直接来自目标服务器,或者经过

    # 1个或者多个额代理。如果一个响应的有效性通过检查,则也可以说它是 first-hand 的

   explicit expiration time
      The time at which the origin server intends that an entity should
      no longer be returned by a cache without further validation.

    # 注释 :explicit expiration time 术语 :由 origin server 决定的某个信息

    # 可以在缓存中的失效时间

   heuristic expiration time
      An expiration time assigned by a cache when no explicit expiration
      time is available.

    # 注释 ;heuristic expiration time 术语 :如果 origin server 没有给消息

    # 分配一个 explicit expiration time ,则由本地缓存分配的一个 expiration tme


   age
      The age of a response is the time since it was sent by, or
      successfully validated with, the origin server.

    # 注释 :age 术语 :一个响应的 age 就是指该响应自动被发出或者被确认有效后,

    # 距离当前的时间。它和下面的 freshness time 有些不同,age 一定小于 freshness time

   freshness lifetime
      The length of time between the generation of a response and its
      expiration time.

    # 注释 :freshness lifetime :指一个响应从被生成到它的 expiration time 之间的时间

   fresh
      A response is fresh if its age has not yet exceeded its freshness
      lifetime.

    # 注释 :fresh 术语 :一个响应如果它的 age 还没有超过 freshness lieftime ,则认为它还是“新鲜的”(fresh)

    # 这就表示还可以用它来响应同样的请求

   stale
      A response is stale if its age has passed its freshness lifetime.

    # 注释 :stale 表示一个响应它的 age 已经过了 freshness lieftime ,这时

    # 要么删除,要么重新确认其有效性

   semantically transparent
      A cache behaves in a "semantically transparent" manner, with
      respect to a particular response, when its use affects neither the
      requesting client nor the origin server, except to improve
      performance. When a cache is semantically transparent, the client
      receives exactly the same response (except for hop-by-hop headers)
      that it would have received had its request been handled directly
      by the origin server.

    # 注释 :semantically transport 术语 :这是对 cache 的工作特点的说明,

    # 就是指缓存的使用不会影响到客户机或者 original server ,如果一个缓存是

    # semantically tarnsparent ,则从缓存获取的响应和从 original server

    # 获得的结果应该是一样的。


   validator
      A protocol element (e.g., an entity tag or a Last-Modified time)
      that is used to find out whether a cache entry is an equivalent
      copy of an entity.

    # 注释 :validator 术语 :它是 HTTP/1.1 协议的一个元素,例如一个 E-tag 或者

    # Last-Modified time 。它用于找出一个缓存的条目是否是最新的

   upstream/downstream
      Upstream and downstream describe the flow of a message: all
      messages flow from upstream to downstream.

    # 注释 :upstream/downstream 术语 :表示一个消息的流向,所有的消息

    # 都是从上游传输到下游的






Fielding, et al.            Standards Track                    [Page 11]

RFC 2616                        HTTP/1.1                       June 1999


   inbound/outbound
      Inbound and outbound refer to the request and response paths for
      messages: "inbound" means "traveling toward the origin server",
      and "outbound" means "traveling toward the user agent"

    # 注释:inbound/outbound 表示一个消息的请求/响应路径。

    # "inbound" 表示“请求进入 origianl server”,“outbound" 则

    # 表示”响应进入客户机“




1.4 Overall Operation

   The HTTP protocol is a request/response protocol. A client sends a
   request to the server in the form of a request method, URI, and
   protocol version, followed by a MIME-like message containing request
   modifiers, client information, and possible body content over a
   connection with a server. The server responds with a status line,
   including the message's protocol version and a success or error code,
   followed by a MIME-like message containing server information, entity
   metainformation, and possible entity-body content. The relationship
   between HTTP and MIME is described in appendix 19.4.、

    # 注释 :HTTP 协议是一个请求/响应协议,一个客户机通过 TCP/IP 连接发送一个请求到服务器,

    # 这个请求包含了请求的 Method(GET、HEAD、POST 等)、URI (/index.html)、协议版本(HTTP /1.1),

    # 跟着一个 MIME-like 消息(可能包含 client modifier、client information、body),

    # 注释:然后服务器返回一个 status line ,它包括消息的协议版本,一个 status code ,

    # 跟着一个 MIME-like 消息(包含 server information、entity information、body)


   Most HTTP communication is initiated by a user agent and consists of
   a request to be applied to a resource on some origin server. In the
   simplest case, this may be accomplished via a single connection (v)
   between the user agent (UA) and the origin server (O).

    # 注释:基本上大部分的 HTTP 通信都是由 User Agent 发起的,

    # 下面是一个最基本的通信模型

          request chain ------------------------>
       UA -------------------v------------------- O
          <----------------------- response chain

   A more complicated situation occurs when one or more intermediaries
   are present in the request/response chain. There are three common
   forms of intermediary: proxy, gateway, and tunnel. A proxy is a
   forwarding agent, receiving requests for a URI in its absolute form,
   rewriting all or part of the message, and forwarding the reformatted
   request toward the server identified by the URI. A gateway is a
   receiving agent, acting as a layer above some other server(s) and, if
   necessary, translating the requests to the underlying server's
   protocol. A tunnel acts as a relay point between two connections
   without changing the messages; tunnels are used when the
   communication needs to pass through an intermediary (such as a
   firewall) even when the intermediary cannot understand the contents
   of the messages.

    # 注释 :但也可以存在很多的中间者,有三种常见的中间者 :代理、网关、隧道

    #     -)1、代理是一个负责转发的代理,接受请求(绝对格式),然后对其进行改写,

                然后转发到 URI 所指定的真正的服务器

    #     -)2、网关是做协议转换的。

    #     -)3、隧道和上面的两种不同,它不对任何消息进行修改,只是负责把两个连接(A-B、B-C)

    #           起来,而且不能使用缓存,也不需要它知道中间传输的数据是什么

          request chain -------------------------------------->
       UA -----v----- A -----v----- B -----v----- C -----v----- O
          <------------------------------------- response chain

   The figure above shows three intermediaries (A, B, and C) between the
   user agent and origin server. A request or response message that
   travels the whole chain will pass through four separate connections.
   This distinction is important because some HTTP communication options



Fielding, et al.            Standards Track                    [Page 12]

RFC 2616                        HTTP/1.1                       June 1999


   may apply only to the connection with the nearest, non-tunnel
   neighbor, only to the end-points of the chain, or to all connections
   along the chain. Although the diagram is linear, each participant may
   be engaged in multiple, simultaneous communications. For example, B
   may be receiving requests from many clients other than A, and/or
   forwarding requests to servers other than C, at the same time that it
   is handling A's request.

   Any party to the communication which is not acting as a tunnel may
   employ an internal cache for handling requests. The effect of a cache
   is that the request/response chain is shortened if one of the
   participants along the chain has a cached response applicable to that
   request. The following illustrates the resulting chain if B has a
   cached copy of an earlier response from O (via C) for a request which
   has not been cached by UA or A.

    # 注释 :使用缓存的结果就是可以缩短 ”请求/响应“链的长度,

    # 例如下面的请求原来是要发给 O 的,但由于 B 上有该请求的答案,

    # 所以直接返回(假设 A 没有该缓存)

          request chain ---------->
       UA -----v----- A -----v----- B - - - - - - C - - - - - - O
          <--------- response chain

   Not all responses are usefully cacheable, and some requests may
   contain modifiers which place special requirements on cache behavior.
   HTTP requirements for cache behavior and cacheable responses are
   defined in section 13.

   In fact, there are a wide variety of architectures and configurations
   of caches and proxies currently being experimented with or deployed
   across the World Wide Web. These systems include national hierarchies
   of proxy caches to save transoceanic bandwidth, systems that
   broadcast or multicast cache entries, organizations that distribute
   subsets of cached data via CD-ROM, and so on. HTTP systems are used
   in corporate intranets over high-bandwidth links, and for access via
   PDAs with low-power radio links and intermittent connectivity. The
   goal of HTTP/1.1 is to support the wide diversity of configurations
   already deployed while introducing protocol constructs that meet the
   needs of those who build web applications that require high
   reliability and, failing that, at least reliable indications of
   failure.

   HTTP communication usually takes place over TCP/IP connections. The
   default port is TCP 80 [19], but other ports can be used. This does
   not preclude HTTP from being implemented on top of any other protocol
   on the Internet, or on other networks. HTTP only presumes a reliable
   transport; any protocol that provides such guarantees can be used;
   the mapping of the HTTP/1.1 request and response structures onto the
   transport data units of the protocol in question is outside the scope
   of this specification.

    # 注释 :HTTP 通信一般是发生在 TCP/IP 连接上,但并不意味着只能使用 TCP/IP

    # 只要能够在底层提供可靠连接的都可以


Fielding, et al.            Standards Track                    [Page 13]

RFC 2616                        HTTP/1.1                       June 1999


   In HTTP/1.0, most implementations used a new connection for each
   request/response exchange. In HTTP/1.1, a connection may be used for
   one or more request/response exchanges, although connections may be
   closed for a variety of reasons (see section 8.1).

    # 注释 :在 HTTP/1.0 中,大部分的实现都是一个请求/响应对应一个连接的,

    # 但在 HTTP/1.1 中,可以做到一个连接承载多个请求/响应,虽然这个连接

    # 最终会因为某些条件被关闭。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics