<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.1" version="1.1">
  <file original="NoName" source-language="en" datatype="plaintext" target-language="zh_Hans">
    <body>
      <trans-unit xml:space="preserve" approved="no" id="a9ff46dfc89a29e8">
        <source>Handshaking</source>
        <target state="translated">握手</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">10</context>
        </context-group>
        <note from="developer">type: section title</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="1f6565aec3da6da2">
        <source>Client Role</source>
        <target state="translated">客户端角色</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">14</context>
        </context-group>
        <note from="developer">type: heading</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="9b463b24fbfbdc84">
        <source>A WebSocket session begins when a client sends the HTTP/1.1 [@https://tools.ietf.org/html/rfc7230#section-6.7 Upgrade] request for [@https://tools.ietf.org/html/rfc6455#section-1.3 WebSocket] on an established connection, and the server sends an appropriate response indicating that the request was accepted and that the connection has been upgraded. The Upgrade request must include the [@https://tools.ietf.org/html/rfc7230#section-5.4 Host] field, and the [@https://tools.ietf.org/html/rfc7230#section-5.3 target] of the resource to request. A typical HTTP Upgrade request created and sent by the implementation will look like this:</source>
        <target state="translated">WebSocket 会话的建立过程如下：客户端在已建立的连接上发送 HTTP/1.1 [@https://tools.ietf.org/html/rfc7230#section-6.7 Upgrade] 请求，服务器则返回相应响应，表示接受该升级请求。该 Upgrade 请求必须包含 [@https://tools.ietf.org/html/rfc7230#section-5.4 Host] 字段以及所请求资源的 [@https://tools.ietf.org/html/rfc7230#section-5.3 目标]。由实现创建并发送的典型 HTTP Upgrade 请求如下所示：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">16</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="4c8d1ec09f124c12">
        <source>WebSocket HTTP Upgrade Request</source>
        <target state="translated">WebSocket HTTP 升级请求</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">30</context>
        </context-group>
        <note from="developer">type: table title</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="30">
        <source>Wire Format</source>
        <target state="translated">线路格式</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">30</context>
        </context-group>
        <note from="developer">type: table cell</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="30">
        <source>Description</source>
        <target state="translated">描述</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">30</context>
        </context-group>
        <note from="developer">type: table cell</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="985ab27953f55fc5">
        <source>GET / HTTP/1.1
Host: www.example.com
Upgrade: websocket
Connection: upgrade
Sec-WebSocket-Key: 2pGeTR0DsE4dfZs2pH+8MA==
Sec-WebSocket-Version: 13
User-Agent: Boost.Beast/216</source>
        <target state="translated">GET / HTTP/1.1
Host: www.example.com
Upgrade: websocket
Connection: upgrade
Sec-WebSocket-Key: 2pGeTR0DsE4dfZs2pH+8MA==
Sec-WebSocket-Version: 13
User-Agent: Boost.Beast/216</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">30</context>
        </context-group>
        <note from="developer">type: table code</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="286208246e07434c">
        <source>The host and target parameters become part of the Host field and request-target in the resulting HTTP request. The key is generated by the implementation. Callers who wish to add, modify, or inspect fields may set the ['decorator] option on the stream (described later).</source>
        <target state="translated">主机和目标参数会分别填入所生成的 HTTP 请求中，分别对应 Host 字段和请求目标。密钥由实现自行生成。如果调用方需要添加、修改或检查字段，可以在流上设置修饰器选项（详见下文）。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">30</context>
        </context-group>
        <note from="developer">type: table cell</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="3a78e999acdc1a24">
        <source>The [link beast.ref.boost__beast__websocket__stream `websocket::stream`] member functions [link beast.ref.boost__beast__websocket__stream.handshake `handshake`] and [link beast.ref.boost__beast__websocket__stream.async_handshake `async_handshake`] are used to send the request with the required host and target strings. This code connects to the IP address returned from a hostname lookup, then performs the WebSocket handshake in the client role.</source>
        <target state="translated">[link beast.ref.boost__beast__websocket__stream `websocket::stream`] 的成员函数 [link beast.ref.boost__beast__websocket__stream.handshake `handshake`] 和 [link beast.ref.boost__beast__websocket__stream.async_handshake `async_handshake`] 用于发送包含所需主机和目标字符串的请求。以下代码先连接到通过主机名解析获得的 IP 地址，然后以客户端角色执行 WebSocket 握手。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">50</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="52acffe7b8df2c78">
        <source>When a client receives an HTTP Upgrade response from the server indicating a successful upgrade, the caller may wish to perform additional validation on the received HTTP response message. For example, to check that the response to a basic authentication challenge is valid. To achieve this, overloads of the handshake member function allow the caller to store the received HTTP message in an output reference argument of type [link beast.ref.boost__beast__websocket__response_type `response_type`] as follows:</source>
        <target state="translated">当客户端收到服务器返回的表示升级成功的 HTTP Upgrade 响应时，调用方可能希望对收到的 HTTP 响应消息进行额外验证。例如，检查基本认证质询的响应是否有效。为此，handshake 成员函数的重载版本允许调用方将收到的 HTTP 消息存储到一个输出引用参数中，该参数类型为 [link beast.ref.boost__beast__websocket__response_type `response_type`]，用法如下：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">61</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="10a3cce6fe5e49a9">
        <source>Server Role</source>
        <target state="translated">服务器角色</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">74</context>
        </context-group>
        <note from="developer">type: heading</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="0eb2e6a7837ad209">
        <source>For servers accepting incoming connections, the [link beast.ref.boost__beast__websocket__stream `websocket::stream`] can read the incoming upgrade request and automatically reply. If the handshake meets the requirements, the stream sends back the upgrade response with a [@https://tools.ietf.org/html/rfc6455#section-4.2.2 ['101 Switching Protocols]] status code. If the handshake does not meet the requirements, or falls outside the range of allowed parameters specified by stream options set previously by the caller, the stream sends back an HTTP response with a status code indicating an error. Depending on the keep alive setting, the connection may remain open for a subsequent handshake attempt. A typical HTTP Upgrade response created and sent by the implementation upon receiving an upgrade request handshake will look like this:</source>
        <target state="translated">对于接受入站连接的服务器，[link beast.ref.boost__beast__websocket__stream `websocket::stream`] 可以读取入站升级请求并自动回复。如果握手满足要求，流会返回一个状态码为 `101 Switching Protocols` 的升级响应。如果握手不符合要求，或超出调用方先前设置的流选项所允许的参数范围，流会返回一个带有错误状态码的 HTTP 响应。根据 keep-alive 设置，连接可能会保持打开状态，以便后续再次尝试握手。当接收到升级请求握手时，实现创建并发送的典型 HTTP 升级响应如下所示：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">76</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="a1d66dc6e888c809">
        <source>WebSocket Upgrade HTTP Response</source>
        <target state="translated">WebSocket 升级 HTTP 响应</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">89</context>
        </context-group>
        <note from="developer">type: table title</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="89">
        <source>Wire Format</source>
        <target state="translated">线路格式</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">89</context>
        </context-group>
        <note from="developer">type: table cell</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="89">
        <source>Description</source>
        <target state="translated">描述</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">89</context>
        </context-group>
        <note from="developer">type: table cell</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="f8348a596d2e21d1">
        <source>HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Server: Boost.Beast</source>
        <target state="translated">HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Server: Boost.Beast</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">89</context>
        </context-group>
        <note from="developer">type: table code</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="ae83c3c961e728d9">
        <source>The [@https://tools.ietf.org/html/rfc6455#section-11.3.3 ['Sec-WebSocket-Accept]] field value is generated from the request in a fashion specified by the WebSocket protocol.</source>
        <target state="translated">[@https://tools.ietf.org/html/rfc6455#section-11.3.3 `Sec-WebSocket-Accept`] 字段值按照 WebSocket 协议规定的方式根据请求生成。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">89</context>
        </context-group>
        <note from="developer">type: table cell</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="f4b13a456cdf0649">
        <source>The [link beast.ref.boost__beast__websocket__stream `stream`] member functions [link beast.ref.boost__beast__websocket__stream.accept `accept`] and [link beast.ref.boost__beast__websocket__stream.async_accept `async_accept`] are used to read the WebSocket HTTP Upgrade request handshake from a stream already connected to an incoming peer, and then send the WebSocket HTTP Upgrade response, as shown:</source>
        <target state="translated">[link beast.ref.boost__beast__websocket__stream `stream`] 的成员函数 [link beast.ref.boost__beast__websocket__stream.accept `accept`] 和 [link beast.ref.boost__beast__websocket__stream.async_accept `async_accept`] 用于从已连接入站对端的流中读取 WebSocket HTTP 升级请求握手，然后发送 WebSocket HTTP 升级响应，用法如下：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">106</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="a877720299ffcfb1">
        <source>Handshake Buffering</source>
        <target state="translated">握手缓冲机制</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">117</context>
        </context-group>
        <note from="developer">type: heading</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="92d44d2bfbbecc2f">
        <source>It is possible for servers to read data from the stream and decide later that the buffered bytes should be interpreted as a WebSocket upgrade request. To address this usage, overloads of [link beast.ref.boost__beast__websocket__stream.accept `accept`] and [link beast.ref.boost__beast__websocket__stream.async_accept `async_accept`] which accept an additional buffer sequence parameter are provided.</source>
        <target state="translated">服务器可能会先读取流中的数据，稍后才决定将这些已缓冲的字节作为 WebSocket 升级请求来处理。为此，该库提供了 [link beast.ref.boost__beast__websocket__stream.accept `accept`] 和 [link beast.ref.boost__beast__websocket__stream.async_accept `async_accept`] 的重载版本，它们接受一个额外的缓冲区序列参数。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">119</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="d8602eb1669fb925">
        <source>In this example, the server reads the initial HTTP request header into a dynamic buffer, then later uses the buffered data to attempt a websocket upgrade.</source>
        <target state="translated">在本示例中，服务器先将初始 HTTP 请求头部读入动态缓冲区，随后使用缓冲数据尝试进行 WebSocket 升级。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">126</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="73578298d6b4c29c">
        <source>Inspecting HTTP Requests</source>
        <target state="translated">检查 HTTP 请求内容</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">132</context>
        </context-group>
        <note from="developer">type: heading</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="e5170d2104ee9ace">
        <source>When implementing an HTTP server that also supports WebSocket, the server usually reads the HTTP request from the client. To detect when the incoming HTTP request is a WebSocket Upgrade request, the function [link beast.ref.boost__beast__websocket__is_upgrade `is_upgrade`] may be used.</source>
        <target state="translated">当实现同时支持 WebSocket 的 HTTP 服务器时，服务器通常需要先读取客户端发来的 HTTP 请求。若要判断该请求是否为 WebSocket 升级请求，可以使用 [link beast.ref.boost__beast__websocket__is_upgrade `is_upgrade`] 函数。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">134</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="4a2fdefb2ad9e581">
        <source>Once the caller determines that the HTTP request is a WebSocket Upgrade, additional overloads of [link beast.ref.boost__beast__websocket__stream.accept `accept`] and [link beast.ref.boost__beast__websocket__stream.async_accept `async_accept`] are provided which receive the entire HTTP request header as an object to perform the handshake. By reading the request manually, the program can handle normal HTTP requests as well as upgrades. The program may also enforce policies based on the HTTP fields, such as Basic Authentication. In this example, the request is first read in using the HTTP algorithms, and then passed to a newly constructed stream:</source>
        <target state="translated">一旦确认 HTTP 请求是 WebSocket 升级请求，就可以使用 [link beast.ref.boost__beast__websocket__stream.accept `accept`] 和 [link beast.ref.boost__beast__websocket__stream.async_accept `async_accept`] 的额外重载版本，这些重载接受整个 HTTP 请求头部对象来完成握手。通过手动读取请求，程序既能处理普通 HTTP 请求，也能处理升级请求。同时，程序还可以基于 HTTP 字段（例如基本认证）来实施策略控制。以下示例先使用 HTTP 算法读取请求，然后将其传递给新构造的流：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">139</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="6eab80d87277f47a">
        <source>Subprotocols</source>
        <target state="translated">子协议</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">153</context>
        </context-group>
        <note from="developer">type: heading</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="638a239e5b4a4cce">
        <source>The WebSocket protocol understands the concept of subprotocols. If the client is requesting one of a set of subprotocols it will set the header [@https://tools.ietf.org/html/rfc6455#section-11.3.4 Sec-WebSocket-Protocol] in the initial WebSocket Upgrade HTTP request. It is up to the server to parse the header and select one of the protocols to accept. The server indicates the selected protocol by setting the [@https://tools.ietf.org/html/rfc6455#section-11.3.4 Sec-WebSocket-Protocol] header in the accept header.</source>
        <target state="translated">WebSocket 协议支持子协议的概念。如果客户端请求使用某个子协议，它会在初始 WebSocket 升级 HTTP 请求中设置 [@https://tools.ietf.org/html/rfc6455#section-11.3.4 Sec-WebSocket-Protocol] 头部。服务器需要解析该头部，并从中选择一个协议接受。服务器通过在响应头部中设置 [@https://tools.ietf.org/html/rfc6455#section-11.3.4 Sec-WebSocket-Protocol] 头部来指示所选协议。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">155</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="bfc5ce4c1f4f4564">
        <source>This is accomplished with a [link beast.ref.boost__beast__websocket__stream_base__decorator `decorator`].</source>
        <target state="translated">这可以通过 [link beast.ref.boost__beast__websocket__stream_base__decorator `decorator`] 来实现。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">164</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="8bc59b2a65db52c2">
        <source>The code that follows demonstrates how a server reads an HTTP request, identifies it as a WebSocket Upgrade, and then checks for a preferred matching subprotocol before performing the WebSocket handshake:</source>
        <target state="translated">以下代码演示服务器如何读取 HTTP 请求，识别其为 WebSocket 升级请求，并在执行 WebSocket 握手之前检查是否存在匹配的优先子协议：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">167</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
    </body>
  </file>
</xliff>
