<?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="47536a66ddf293f3">
        <source>HTTP Examples</source>
        <target state="translated">HTTP 示例</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="a376447cf7a69e50">
        <source>These examples in this section are working functions that may be found in the examples directory. They demonstrate the usage of the library for a variety of scenarios.</source>
        <target state="translated">本节提供的示例均为可运行函数，存放于 examples 目录中。这些示例展示了该库在不同场景下的具体用法。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">12</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="ce86508f783c6d9a">
        <source>Change Body Type __example__</source>
        <target state="translated">修改消息体类型 __示例__</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">18</context>
        </context-group>
        <note from="developer">type: section title</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="a8b5cba323cba2c5">
        <source>Sophisticated servers may wish to defer the choice of the Body template type until after the header is available. Then, a body type may be chosen depending on the header contents. For example, depending on the verb, target path, or target query parameters. To accomplish this, a parser is declared to read in the header only, using a trivial body type such as [link beast.ref.boost__beast__http__empty_body `empty_body`]. Then, a new parser is constructed from this existing parser where the body type is conditionally determined by information from the header or elsewhere.</source>
        <target state="translated">高级服务器可能希望等到获取头部信息后，再决定使用哪种 Body 模板类型。这样就能根据头部内容（例如请求方法、目标路径或查询参数）来选用合适的消息体类型。具体做法是：先使用一个简单的消息体类型（如 [link beast.ref.boost__beast__http__empty_body `empty_body`]）声明解析器，只用于读取头部。然后，基于这个已有的解析器构造一个新的解析器，并根据头部或其他信息来确定新解析器的消息体类型。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">20</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="8c2719ad65f51b06">
        <source>This example illustrates how a server may make the commitment of a body type depending on the method verb:</source>
        <target state="translated">本示例演示服务器如何根据请求方法来决定使用哪种消息体类型：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">29</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="1a7f577c4d1832c5">
        <source>Expect 100-continue (Client) __example__</source>
        <target state="translated">Expect: 100-continue（客户端） __示例__</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">38</context>
        </context-group>
        <note from="developer">type: section title</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="ef1867d840e85ae8">
        <source>The Expect field with the value "100-continue" in a request is special. It indicates that the after sending the message header, a client desires an immediate informational response before sending the message body, which presumably may be expensive to compute or large. This behavior is described in [@https://tools.ietf.org/html/rfc7231#section-5.1.1 rfc7231 section 5.1.1]. Invoking the 100-continue behavior is implemented easily in a client by constructing a __serializer__ to send the header first, then receiving the server response, and finally conditionally send the body using the same serializer instance. A synchronous, simplified version (no timeout) of this client action looks like this:</source>
        <target state="translated">请求中的 Expect 字段若值为 `100-continue`，则具有特殊含义。它表示客户端在发送消息头部之后，希望在发送消息体之前立即收到一个信息性响应。这通常是因为消息体的计算开销较大或数据量较大。[@https://tools.ietf.org/html/rfc7231#section-5.1.1 rfc7231 第 5.1.1 节] 对此行为进行了详细说明。在客户端实现 100-continue 行为比较简单：先构造 __serializer__ 发送头部，然后接收服务器响应，最后根据情况使用同一个序列化器实例发送消息体。以下是一个同步的简化版本（不含超时）的实现：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">40</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="09f0abefd10722db">
        <source>Expect 100-continue (Server) __example__</source>
        <target state="translated">Expect: 100-continue（服务器） __示例__</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">57</context>
        </context-group>
        <note from="developer">type: section title</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="b67f8163c7134ad1">
        <source>The Expect field with the value "100-continue" in a request is special. It indicates that the after sending the message header, a client desires an immediate informational response before sending the message body, which presumably may be expensive to compute or large. This behavior is described in [@https://tools.ietf.org/html/rfc7231#section-5.1.1 rfc7231 section 5.1.1]. Handling the Expect field can be implemented easily in a server by constructing a __parser__ to read the header first, then send an informational HTTP response, and finally read the body using the same parser instance. A synchronous version of this server action looks like this:</source>
        <target state="translated">请求中的 Expect 字段若值为 `100-continue`，则具有特殊含义。它表示客户端在发送消息头部之后，希望在发送消息体之前立即收到一个信息性响应。这通常是因为消息体的计算开销较大或数据量较大。[@https://tools.ietf.org/html/rfc7231#section-5.1.1 rfc7231 第 5.1.1 节] 对此行为进行了详细说明。在服务器端处理 Expect 字段较为简单：先构造一个 __parser__ 读取头部，然后发送一个信息性 HTTP 响应，最后使用同一个解析器实例读取消息体。以下是一个同步版本的服务器实现：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">59</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="7acc1958315ab1e8">
        <source>HEAD request (Client) __example__</source>
        <target state="translated">HEAD 请求（客户端） __示例__</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">75</context>
        </context-group>
        <note from="developer">type: section title</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="f580f3328c69af1c">
        <source>The [@https://tools.ietf.org/html/rfc7231#section-4.3.2 HEAD request] method indicates to the server that the client wishes to receive the entire header that would be delivered if the method was GET, except that the body is omitted. When a client wishes to receive the response to a HEAD request, it is necessary to inform the parser not to expect a body. This is done by calling [link beast.ref.boost__beast__http__basic_parser.skip `basic_parser::skip`] with the value `true`, as shown in this example:</source>
        <target state="translated">[@https://tools.ietf.org/html/rfc7231#section-4.3.2 HEAD 请求] 方法表示客户端希望服务器返回与 GET 请求相同的头部信息，但不包含消息体。当客户端需要接收 HEAD 请求的响应时，必须告知解析器不需要消息体。这可以通过调用 [link beast.ref.boost__beast__http__basic_parser.skip `basic_parser::skip`] 并传入 `true` 来实现，如下例所示：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">77</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="fce6fc1553f72d20">
        <source>HEAD response (Server) __example__</source>
        <target state="translated">HEAD 响应（服务器） __示例__</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">93</context>
        </context-group>
        <note from="developer">type: section title</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="4f9d701e2265e5f7">
        <source>When a server receives a [@https://tools.ietf.org/html/rfc7231#section-4.3.2 HEAD request], the response should contain the entire header that would be delivered if the method was GET, except that the body is omitted.</source>
        <target state="translated">当服务器收到 [@https://tools.ietf.org/html/rfc7231#section-4.3.2 HEAD 请求] 时，响应应包含与 GET 请求相同的完整头部信息，但不包含消息体。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">95</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="baeba89c440f759b">
        <source>HTTP Relay __example__</source>
        <target state="translated">HTTP 中继 __示例__</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">106</context>
        </context-group>
        <note from="developer">type: section title</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="489dedf4ac3de323">
        <source>An HTTP proxy acts as a relay between client and server. The proxy reads a request from the client and sends it to the server, possibly adjusting some of the headers and representation of the body along the way. Then, the proxy reads a response from the server and sends it back to the client, also with the possibility of changing the headers and body representation.</source>
        <target state="translated">HTTP 代理充当客户端与服务器之间的中继。代理从客户端读取请求并将其发送至服务器，其间可能会对部分头部字段及消息体表示形式进行调整。随后，代理从服务器读取响应并将其返回给客户端，同样可能对头部和消息体进行修改。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">108</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="0b2c1d1e888c45f2">
        <source>The example that follows implements a synchronous HTTP relay. It uses a fixed size buffer, to avoid reading in the entire body so that the upstream connection sees a header without unnecessary latency. This example brings together all of the concepts discussed so far, it uses both a __serializer__ and a __parser__ to achieve its goal:</source>
        <target state="translated">以下示例实现一个同步的 HTTP 中继。它使用固定大小的缓冲区，避免一次性读取整个消息体，从而使上游连接能够更及时地看到头部信息，减少不必要的延迟。该示例综合运用了此前讨论的所有概念，通过同时使用 __serializer__ 和 __parser__ 来实现目标：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">114</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="0189cda0f0101297">
        <source>Send Child Process Output __example__</source>
        <target state="translated">发送子进程输出 __示例__</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">126</context>
        </context-group>
        <note from="developer">type: section title</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="4996df7139ad0c42">
        <source>Sometimes it is necessary  to send a message whose body is not conveniently described by a single container. For example, when implementing an HTTP relay function a robust implementation needs to present body buffers individually as they become available from the downstream host. These buffers should be fixed in size, otherwise creating the unnecessary and inefficient burden of reading the complete message body before forwarding it to the upstream host.</source>
        <target state="translated">有时需要发送的消息体并不适合用单个容器来描述。例如，在实现 HTTP 中继功能时，一个健壮的实现需要从下游主机逐个获取可用的消息体缓冲区。这些缓冲区应具有固定大小，否则会造成不必要的低效负担——在转发到上游主机之前必须先读取完整的消息体。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">128</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="b61daaeb9570dd6c">
        <source>To enable these use-cases, the body type __buffer_body__ is provided. This body uses a caller-provided pointer and size instead of an owned container. To use this body, instantiate an instance of the serializer and fill in the pointer and size fields before calling a stream write function.</source>
        <target state="translated">为支持这类使用场景，该库提供了 __buffer_body__ 消息体类型。该消息体使用调用方提供的指针和大小，而非自身拥有的容器。使用此消息体时，需要先实例化一个序列化器，并在调用流写入函数之前填充指针和大小字段。</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">135</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
      <trans-unit xml:space="preserve" approved="no" id="047c7166182f8f56">
        <source>This example reads from a child process and sends the output back in an HTTP response. The output of the process is sent as it becomes available:</source>
        <target state="translated">本示例从子进程读取输出，并将其以 HTTP 响应的形式发送回去。进程的输出会在可用时立即发送：</target>
        <context-group name="" purpose="location">
          <context context-type="sourcefile">140</context>
        </context-group>
        <note from="developer">type: paragraph</note>
      </trans-unit>
    </body>
  </file>
</xliff>
