From 34890aa47d3ee7af37be2faddb9b13bf42fe3342 Mon Sep 17 00:00:00 2001 From: Boost-tran Date: Fri, 26 Jun 2026 20:24:34 +0000 Subject: [PATCH 1/7] Translated using Weblate (Chinese (Simplified Han script)) Currently translated at 100.0% (53 of 53 strings) Translation: Boost Beast Translation (zh_Hans)/Doc / Qbk / 03 Core / 1 Refresher (qbk) Translate-URL: https://insights.cppalliance.org/weblate/projects/boost-beast-documentation-zh_Hans/doc-qbk-03-core-1-refresher-qbk/zh_Hans/ --- doc/qbk/03_core/1_refresher_zh_Hans.qbk | 85 +++++-------------------- 1 file changed, 15 insertions(+), 70 deletions(-) diff --git a/doc/qbk/03_core/1_refresher_zh_Hans.qbk b/doc/qbk/03_core/1_refresher_zh_Hans.qbk index a8242e1..2bea8b6 100644 --- a/doc/qbk/03_core/1_refresher_zh_Hans.qbk +++ b/doc/qbk/03_core/1_refresher_zh_Hans.qbk @@ -130,108 +130,53 @@ __AsyncReadStream__ 与 __AsyncWriteStream__ 概念用于定义 [异步流] 的 [heading 通用模型] -Because completion handlers cause an inversion of the flow of control, -sometimes other methods of attaching a continuation are desired. Networking -provides the -[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3747.pdf ['Universal Model for Asynchronous Operations]], -providing a customizable means for transforming the signature of the initiating -function to use other types of objects and methods in place of a completion -handler callback. For example to call to write a string to a socket -asynchronously, using a `std::future` to receive the number of bytes transferred -thus looks like this: +由于完成处理器会导致控制流反转,有时需要其他方式来附加延续。网络库提供 [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3747.pdf [异步操作通用模型]],该模型提供一种可定制的方法,用于改变发起函数的签名,以便使用其他类型的对象和方法来替代完成处理器回调。例如,使用 `std::future` 接收传输字节数来异步向套接字写入字符串的调用方式如下: [code_core_1_refresher_4s] -This functionality is enabled by passing the variable -[@boost:/doc/html/boost_asio/reference/use_future.html `net::use_future`] -(of type -[@boost:/doc/html/boost_asio/reference/use_future_t.html `net::use_future_t<>`]) -in place of the completion handler. The same `async_write` function overload -can work with a -[@https://en.wikipedia.org/wiki/Fiber_(computer_science) ['fiber]] -launched with -[@boost:/doc/html/boost_asio/reference/spawn/overload1.html `asio::spawn`]: +此功能通过将变量 [@boost:/doc/html/boost_asio/reference/use_future.html `net::use_future`](类型为 [@boost:/doc/html/boost_asio/reference/use_future_t.html `net::use_future_t<>`])传递给完成处理器位置来实现。同一个 `async_write` 函数重载还可以与通过 [@boost:/doc/html/boost_asio/reference/spawn/overload1.html `asio::spawn`] 启动的 [@https://en.wikipedia.org/wiki/Fiber_(computer_science) [纤程]] 配合使用: [code_core_1_refresher_5s] -In both of these cases, an object with a specific type is used in place of -the completion handler, and the return value of the initiating function -is transformed from `void` to `std::future` or `std::size_t`. -The handler is sometimes called a -__CompletionToken__ -when used in this context. The return type transformation is supported by -customization points in the initiating function signature. Here is the -signature for -[@boost:/doc/html/boost_asio/reference/async_write/overload1.html `net::async_write`]: +在这两种情况下,都使用具有特定类型的对象来替代完成处理器,且发起函数的返回值也从 `void` 转变为 `std::future` 或 `std::size_t`。在这种上下文中,该处理器有时被称为 __CompletionToken__。发起函数签名中的定制点支持这种返回值类型的转换。以下是 [@boost:/doc/html/boost_asio/reference/async_write/overload1.html `net::async_write`] 的签名: -Note that a `spawn` function itself has a completion signature, -but we're ignoring it's result in the example by using `asio::detached`. +需要注意的是,`spawn` 函数本身也带有完成签名,但示例中通过使用 `asio::detached` 忽略了它的结果。 [code_core_1_refresher_9] -The type of the function's return value is determined by the -[@boost:/doc/html/boost_asio/reference/async_result.html `net::async_result`] -customization point, which comes with specializations for common library -types such as `std::future` and may also be specialized for user-defined -types. The body of the initiating function calls the -[@boost:/doc/html/boost_asio/reference/async_initiate.html `net::async_initiate`] -helper to capture the arguments and forward them to the specialization of -`async_result`. An additional "initiation function" object is provided which -`async_result` may use to immediately launch the operation, or defer the launch -of the operation until some point in the future (this is called "lazy -execution"). The initiation function object receives the internal completion -handler which matches the signature expected by the initiating function: +函数返回值类型由 [@boost:/doc/html/boost_asio/reference/async_result.html `net::async_result`] 定制点决定。该定制点为 `std::future` 等常用库类型提供特化版本,同时也支持用户自定义类型的特化。发起函数的函数体通过调用 [@boost:/doc/html/boost_asio/reference/async_initiate.html `net::async_initiate`] 辅助函数来捕获参数并将其转发给 `async_result` 的特化版本。此外,还提供一个额外的“发起函数”对象,`async_result` 可利用该对象立即启动操作,或将操作启动延迟到未来某个时刻(即“延迟执行”)。该发起函数对象接收一个内部完成处理器,其签名与发起函数所期望的签名相匹配。 [code_core_1_refresher_10] -This transformed, internal handler is responsible for the finalizing step that -delivers the result of the operation to the caller. For example, when using -`net::use_future` the internal handler will deliver the result by calling -[@https://en.cppreference.com/w/cpp/thread/promise/set_value `std::promise::set_value`] -on the promise object returned by the initiating function. +这个经过转换的内部处理器负责执行最终步骤,将操作结果传递给调用方。例如,当使用 `net::use_future` 时,内部处理器会通过调用发起函数返回的 promise 对象上的 [@https://en.cppreference.com/w/cpp/thread/promise/set_value `std::promise::set_value`] 来传递结果。 [/-----------------------------------------------------------------------------] -[heading Using Networking] +[heading 使用网络库] -Most library stream algorithms require a __socket__, __ssl_stream__, or -other __Stream__ object that has already established communication with -a remote peer. This example is provided as a reminder of how to work with -sockets: +大多数库中的流算法都需要一个已与远程对等端建立通信的 __socket__、__ssl_stream__ 或其他 __Stream__ 对象。以下示例用于回顾如何使用套接字: [snippet_core_2] -Throughout this documentation identifiers with the following names have -special meaning: +在本文档中,以下名称的标识符具有特殊含义: -[table Global Variables -[[Name][Description]] +[table 全局变量 +[[名称][描述]] [[ [@boost:/doc/html/boost_asio/reference/io_context.html [*`ioc`]] -][ - A variable of type __io_context__ which is running on one separate thread, - and upon which an __executor_work_guard__ object has been constructed. +][一个类型为 __io_context__ 的变量,该变量在单独线程上运行,且已为其构造一个 __executor_work_guard__ 对象。 ]] [[ [@boost:/doc/html/boost_asio/reference/ip__tcp/socket.html [*`sock`]] -][ - A variable of type - [@boost:/doc/html/boost_asio/reference/ip__tcp/socket.html `tcp::socket`] - which has already been connected to a remote host. +][一个类型为 [@boost:/doc/html/boost_asio/reference/ip__tcp/socket.html `tcp::socket`] 的变量,该变量已连接到远程主机。 ]] [[ [@boost:/doc/html/boost_asio/reference/ssl__stream.html [*`ssl_sock`]] -][ - A variable of type - [@boost:/doc/html/boost_asio/reference/ssl__stream.html `net::ssl::stream`] - which is already connected and has handshaked with a remote host. +][一个类型为 [@boost:/doc/html/boost_asio/reference/ssl__stream.html `net::ssl::stream`] 的变量,该变量已与远程主机建立连接并完成握手。 ]] [[ [link beast.ref.boost__beast__websocket__stream [*`ws`]] -][ - A variable of type - [link beast.ref.boost__beast__websocket__stream `websocket::stream`] - which is already connected with a remote host. +][一个类型为 [link beast.ref.boost__beast__websocket__stream `websocket::stream`] 的变量,该变量已与远程主机建立连接。 ]] ] From 50bc3178b5ce0001d9b6103746514c1649b5e355 Mon Sep 17 00:00:00 2001 From: Boost-tran Date: Fri, 26 Jun 2026 20:24:34 +0000 Subject: [PATCH 2/7] Translated using Weblate (Chinese (Simplified Han script)) Currently translated at 100.0% (50 of 50 strings) Translation: Boost Beast Translation (zh_Hans)/Doc / Qbk / 08 Design / 1 Http Message (qbk) Translate-URL: https://insights.cppalliance.org/weblate/projects/boost-beast-documentation-zh_Hans/doc-qbk-08-design-1-http-message-qbk/zh_Hans/ --- doc/qbk/08_design/1_http_message_zh_Hans.qbk | 234 ++++--------------- 1 file changed, 42 insertions(+), 192 deletions(-) diff --git a/doc/qbk/08_design/1_http_message_zh_Hans.qbk b/doc/qbk/08_design/1_http_message_zh_Hans.qbk index cd3154c..af11e2e 100644 --- a/doc/qbk/08_design/1_http_message_zh_Hans.qbk +++ b/doc/qbk/08_design/1_http_message_zh_Hans.qbk @@ -9,14 +9,9 @@ ] -[section:http_message_container HTTP Message Container __video__] +[section:http_message_container HTTP 消息容器 __video__] -The following video presentation was delivered at -[@https://cppcon.org/ CppCon] -in 2017. The presentation provides a simplified explanation of the design -process for the HTTP message container used in Beast. The slides and code -used are available in the -[@https://github.com/vinniefalco/CppCon2017 GitHub repository]. +以下视频演示是在 2017 年的 [@https://cppcon.org/ CppCon] 上发表的。该演示简要介绍了 Beast 中使用的 HTTP 消息容器的设计过程。演示所用的幻灯片和代码可在 [@https://github.com/vinniefalco/CppCon2017 GitHub 仓库] 中找到。 [/ "Make Classes Great Again! (Using Concepts for Customization Points)"] [block''' @@ -28,39 +23,28 @@ used are available in the '''] -In this section we describe the problem of modeling HTTP messages and explain -how the library arrived at its solution, with a discussion of the benefits -and drawbacks of the design choices. The goal for creating a message model -is to create a container with value semantics, possibly movable and/or -copyable, that contains all the information needed to serialize, or all -of the information captured during parsing. More formally, given: +在本节中,我们将探讨 HTTP 消息建模所面临的挑战,并阐述该库是如何推导出最终解决方案的,同时也会深入剖析这些设计选择的利弊。构建消息模型的核心目标,是打造一个具备值语义(value semantics)的容器(支持移动和/或复制),使其能够囊括序列化所需的全部信息,或是完整保留解析过程中捕获的所有数据。从更严谨的层面来说,给定: -* `m` is an instance of an HTTP message container +* `m` 是 HTTP 消息容器的一个实例 -* `x` is a series of octets describing a valid HTTP message in +* `x` 是一系列字节(octets),用于描述一个有效的 HTTP 消息 the serialized format described in __rfc7230__. -* `S(m)` is a serialization function which produces a series of octets +* `S(m)` 是一个序列化函数,用于生成一系列字节(octets) from a message container. -* `P(x)` is a parsing function which produces a message container from +* `P(x)` 是一个解析函数,用于从……生成一个消息容器 a series of octets. -These relations are true: +以下关系成立: * `S(m) == x` * `P(S(m)) == m` -We would also like our message container to have customization points -permitting the following: allocator awareness, user-defined containers -to represent header fields, and user-defined types and algorithms to -represent the body. And finally, because requests and responses have -different fields in the ['start-line], we would like the containers for -requests and responses to be represented by different types for function -overloading. +此外,我们还希望消息容器提供自定义扩展点,以实现以下功能:支持分配器感知(allocator awareness)、允许使用用户自定义的容器来表示首部字段,以及支持使用用户自定义的类型和算法来表示消息体。最后,由于请求和响应的起始行(start-line)包含不同的字段,我们希望分别使用不同的类型来表示请求和响应的容器,从而支持函数重载。 -Here is our first attempt at declaring some message containers: +这是我们首次尝试声明一些消息容器: [table [[ @@ -94,29 +78,11 @@ struct response ]] ] -These containers are capable of representing everything in the model -of HTTP requests and responses described in __rfc7230__. Request and -response objects are different types. The user can choose the container -used to represent the fields. And the user can choose the [*Body] type, -which is a concept defining not only the type of `body` member but also -the algorithms used to transfer information in and out of that member -when performing serialization and parsing. - -However, a problem arises. How do we write a function which can accept -an object that is either a request or a response? As written, the only -obvious solution is to make the message a template type. Additional traits -classes would then be needed to make sure that the passed object has a -valid type which meets the requirements. These unnecessary complexities -are bypassed by making each container a partial specialization: -``` -/// An HTTP message -template -struct message; +这些容器能够完整地表达 RFC 7230 中描述的 HTTP 请求和响应模型。请求对象和响应对象是两种不同的类型。用户可以选择用于表示首部字段的容器。此外,用户还可以选择 `Body` 类型,该类型不仅定义了 `body` 成员的类型,还规定了在序列化和解析过程中,信息进出该成员所使用的算法。 -/// An HTTP request -template -struct message -{ +然而,问题随之而来。如何编写一个既能接受请求对象又能接受响应对象的函数呢?按照当前的写法,最显而易见的解决方案是将消息类型设为模板参数。这样一来,还需要额外的特征类(traits classes)来确保传入的对象具有符合要求的有效类型。为了避免这些不必要的复杂性,我们可以将每个容器设计为偏特化(partial specialization):```/// An HTTP message template struct message; + +/// 一个 HTTP 请求模板 struct message { int version; std::string method; std::string target; @@ -125,10 +91,7 @@ struct message typename Body::value_type body; }; -/// An HTTP response -template -struct message -{ +/// 一个 HTTP 响应模板 struct message { int version; int status; std::string reason; @@ -138,19 +101,9 @@ struct message }; ``` -Now we can declare a function which takes any message as a parameter: -``` -template -void f(message& msg); -``` +现在,我们可以声明一个能够接受任意消息作为参数的函数了:``` template void f(message& msg); ``` -This function can manipulate the fields common to requests and responses. -If it needs to access the other fields, it can use overloads with -partial specialization, or in C++17 a `constexpr` expression: -``` -template -void f(message& msg) -{ +该函数可以处理请求和响应共有的字段。如果需要访问其他字段,则可以使用基于偏特化的重载,或者在 C++17 中使用 constexpr 表达式:``` template void f(message& msg) { if constexpr(isRequest) { // call msg.method(), msg.target() @@ -162,48 +115,21 @@ void f(message& msg) } ``` -Often, in non-trivial HTTP applications, we want to read the HTTP header -and examine its contents before choosing a type for [*Body]. To accomplish -this, there needs to be a way to model the header portion of a message. -And we'd like to do this in a way that allows functions which take the -header as a parameter, to also accept a type representing the whole -message (the function will see just the header part). This suggests -inheritance, by splitting a new base class off of the message: -``` -/// An HTTP message header -template -struct header; -``` +通常,在非平凡的 HTTP 应用程序中,我们希望在为 [*Body] 选择类型之前,先读取 HTTP 头部并检查其内容。为了实现这一点,需要有一种方法来对消息的头部部分进行建模。并且,我们希望以这样的方式来实现:让那些将头部作为参数的函数,也能够接受代表整个消息的类型(函数只会看到头部部分)。这表明可以通过从 message 中分离出一个新的基类来使用继承:``` /// An HTTP message header template struct header; ``` -Code which accesses the fields has to laboriously mention the `fields` -member, so we'll not only make `header` a base class but we'll make -a quality of life improvement and derive the header from the fields -for notational convenience. In order to properly support all forms -of construction of [*Fields] there will need to be a set of suitable -constructor overloads (not shown): -``` -/// An HTTP request header -template -struct header : Fields -{ +访问字段的代码不得不反复显式引用 `fields` 成员,这显得十分繁琐。因此,我们不仅将 `header` 作为基类,还会为了书写便利进行一项优化:让 `header` 直接从 `fields` 派生。为了能够正确支持对 [*Fields] 的所有构造形式,还需要提供一组合适的构造函数重载(此处未展示):``` /// An HTTP request header template struct header : Fields { int version; std::string method; std::string target; }; -/// An HTTP response header -template -struct header : Fields -{ +/// 一个 HTTP 响应头部 template struct header : Fields { int version; int status; std::string reason; }; -/// An HTTP message -template -struct message : header -{ +/// 一个 HTTP 消息 template struct message : header { typename Body::value_type body; /// Construct from a `header` @@ -212,48 +138,15 @@ struct message : header ``` -Note that the `message` class now has a constructor allowing messages -to be constructed from a similarly typed `header`. This handles the case -where the user already has the header and wants to make a commitment to the -type for [*Body]. A function can be declared which accepts any header: -``` -template -void f(header& msg); -``` +请注意,`message` 类现在拥有一个构造函数,允许从类型相同的 `header` 构造消息。这解决了用户已经拥有头部,并希望为 [*Body] 确定具体类型的情况。我们可以声明一个能够接受任意头部的函数: ``` template void f(header& msg); ``` -Until now we have not given significant consideration to the constructors -of the `message` class. But to achieve all our goals we will need to make -sure that there are enough constructor overloads to not only provide for -the special copy and move members if the instantiated types support it, -but also allow the fields container and body container to be constructed -with arbitrary variadic lists of parameters. This allows the container -to fully support allocators. - -The solution used in the library is to treat the message like a `std::pair` -for the purposes of construction, except that instead of `first` and `second` -we have the `Fields` base class and `message::body` member. This means that -single-argument constructors for those fields should be accessible as they -are with `std::pair`, and that a mechanism identical to the pair's use of -`std::piecewise_construct` should be provided. Those constructors are too -complex to repeat here, but interested readers can view the declarations -in the corresponding header file. - -There is now significant progress with our message container but a stumbling -block remains. There is no way to control the allocator for the `std::string` -members. We could add an allocator to the template parameter list of the -header and message classes, use it for those strings. This is unsatisfying -because of the combinatorial explosion of constructor variations needed to -support the scheme. It also means that request messages could have [*four] -different allocators: two for the fields and body, and two for the method -and target strings. A better solution is needed. - -To get around this we make an interface modification and then add -a requirement to the [*Fields] type. First, the interface change: -``` -/// An HTTP request header -template -struct header : Fields -{ +到目前为止,我们还没有对 `message` 类的构造函数给予足够的重视。但为了实现所有目标,我们必须确保提供足够多的构造函数重载。这不仅需要在实例化的类型支持时提供特殊的拷贝和移动成员,还需要允许使用任意的可变参数列表来构造字段容器和主体容器。这使得容器能够完全支持分配器。 + +库中采用的解决方案是:在构造 `message` 时,将其视作 `std::pair` 来处理。不同的是,原本 `std::pair` 中的 `first` 和 `second` 在这里被替换成了 `Fields` 基类和 `message::body` 成员。这意味着,这些字段的单参数构造函数应当像 `std::pair` 一样易于调用,并且需要提供一套与 `std::pair` 的 `std::piecewise_construct` 完全相同的机制。由于这些构造函数的实现较为复杂,这里不再赘述,感兴趣的读者可以直接查阅相应头文件中的声明。 + +尽管我们的消息容器已经取得了显著进展,但仍面临一个棘手的问题:目前无法控制 `std::string` 成员的分配器。虽然可以在 `header` 和 `message` 类的模板参数列表中添加一个分配器来管理这些字符串,但这并不是一个令人满意的方案。因为这需要引入数量庞大的构造函数重载来支持该机制,导致组合爆炸。此外,这也意味着请求消息可能会拥有多达四种不同的分配器:其中两个分别用于字段和主体,另外两个则用于方法(method)和目标(target)字符串。因此,我们需要寻找一个更好的解决方案。 + +为了解决这个问题,我们首先对接口进行修改,然后对 `Fields` 类型增加一项要求。首先是接口层面的改动:``` /// 一个 HTTP 请求头部 template struct header : Fields { int version; verb method() const; @@ -268,10 +161,7 @@ private: verb method_; }; -/// An HTTP response header -template -struct header : Fields -{ +/// 一个 HTTP 响应头部 template struct header : Fields { int version; int result; string_view reason() const; @@ -279,22 +169,9 @@ struct header : Fields }; ``` -The start-line data members are replaced by traditional accessors -using non-owning references to string buffers. The method is stored -using a simple integer instead of the entire string, for the case -where the method is recognized from the set of known verb strings. - -Now we add a requirement to the fields type: management of the -corresponding string is delegated to the [*Fields] container, which can -already be allocator aware and constructed with the necessary allocator -parameter via the provided constructor overloads for `message`. The -delegation implementation looks like this (only the response header -specialization is shown): -``` -/// An HTTP response header -template -struct header : Fields -{ +起始行(start-line)的数据成员被替换成传统的访问器(accessors),它们通过不持有所有权的引用来指向字符串缓冲区。此外,对于能从已知动词字符串集合中识别出的方法(method),系统直接使用一个简单的整数来存储,而不再保存完整的字符串。 + +对 `Fields` 类型增加一项要求:将对应字符串的管理委托给 `Fields` 容器。该容器本身已具备分配器感知能力,且可通过 `message` 提供的构造函数重载,使用必要的分配器参数进行构造。委托的实现方式如下(仅展示响应头部的特化版本):``` /// 一个 HTTP 响应头部 template struct header : Fields { int version; int status; @@ -312,50 +189,23 @@ struct header : Fields }; ``` -Now that we've accomplished our initial goals and more, there are a few -more quality of life improvements to make. Users will choose different -types for `Body` far more often than they will for `Fields`. Thus, we -swap the order of these types and provide a default. Then, we provide -type aliases for requests and responses to soften the impact of using -`bool` to choose the specialization: +初步目标已超额达成,接下来还需进行一些提升易用性的改进。由于用户为 `Body` 选择自定义类型的频率远高于为 `Fields` 选择,因此将这两者的模板参数顺序互换,并为 `Fields` 提供默认类型。随后,为请求和响应提供类型别名,以缓解直接使用 `bool` 来选择特化版本带来的不便: -``` -/// An HTTP header -template -struct header; +``` /// 一个 HTTP 头部 template struct header; -/// An HTTP message -template -struct message; +/// 一个 HTTP 消息 template struct message; -/// An HTTP request -template -using request = message; +/// 一个 HTTP 请求 template using request = message; -/// An HTTP response -template -using response = message; -``` +/// 一个 HTTP 响应 template using response = message; ``` -This allows concise specification for the common cases, while -allowing for maximum customization for edge cases: -``` -request req; +这样既能以简洁的方式满足常见需求,又能为边缘情况提供最大程度的定制空间:``` request req; response res; ``` -This container is also capable of representing complete HTTP/2 messages. -Not because it was explicitly designed for, but because the IETF wanted to -preserve message compatibility with HTTP/1. Aside from version specific -fields such as Connection, the contents of HTTP/1 and HTTP/2 messages are -identical even though their serialized representation is considerably -different. The message model presented in this library is ready for HTTP/2. - -In conclusion, this representation for the message container is well thought -out, provides comprehensive flexibility, and avoids the necessity of defining -additional traits classes. User declarations of functions that accept headers -or messages as parameters are easy to write in a variety of ways to accomplish -different results, without forcing cumbersome SFINAE declarations everywhere. +该容器同样能够表示完整的 HTTP/2 消息。这并非因为它是为此而专门设计的,而是因为 IETF 希望保持与 HTTP/1 的消息兼容性。除了像 `Connection` 这类特定于版本的字段之外,HTTP/1 和 HTTP/2 消息的内容是完全相同的,尽管它们的序列化表示形式存在显著差异。因此,本库中展示的消息模型已经为 HTTP/2 做好了准备。 + +综上所述,这种消息容器的表示方式经过深思熟虑,提供了全面的灵活性,并且免去了定义额外特征类(traits classes)的必要。用户声明接受头部或消息作为参数的函数时,可以通过多种方式轻松编写,以实现不同的目的,而无需在代码中到处使用繁琐的 SFINAE 声明。 [endsect] From dbc4fc31dd4a635cdfea83638294ce79bc5c00f1 Mon Sep 17 00:00:00 2001 From: Boost-tran Date: Fri, 26 Jun 2026 20:24:34 +0000 Subject: [PATCH 3/7] Translated using Weblate (Chinese (Simplified Han script)) Currently translated at 100.0% (23 of 23 strings) Translation: Boost Beast Translation (zh_Hans)/Doc / Qbk / 07 Concepts / Body (qbk) Translate-URL: https://insights.cppalliance.org/weblate/projects/boost-beast-documentation-zh_Hans/doc-qbk-07-concepts-body-qbk/zh_Hans/ --- doc/qbk/07_concepts/Body_zh_Hans.qbk | 79 ++++++++-------------------- 1 file changed, 22 insertions(+), 57 deletions(-) diff --git a/doc/qbk/07_concepts/Body_zh_Hans.qbk b/doc/qbk/07_concepts/Body_zh_Hans.qbk index 56c8397..d5f9cd7 100644 --- a/doc/qbk/07_concepts/Body_zh_Hans.qbk +++ b/doc/qbk/07_concepts/Body_zh_Hans.qbk @@ -7,54 +7,38 @@ Official repository: https://github.com/boostorg/beast ] -[section:Body Body] +[section:Body 消息体] -A [*Body] type is supplied as a template argument to the __message__ class. It -controls both the type of the data member of the resulting message object, and -the algorithms used during parsing and serialization. +[*Body] 类型作为模板参数传递给 __message__ 类。它决定结果消息对象中数据成员的类型,以及解析和序列化所用算法。 -[heading Associated Types] +[heading 关联类型] * [link beast.ref.boost__beast__http__is_body `is_body`] * __BodyReader__ * __BodyWriter__ -[heading Requirements] +[heading 要求] -In this table: +在下表中: -* `B` is a type meeting the requirements of [*Body]. -* `m` is a value of type `message` where `b` is a `bool` value +* `B` 是一个满足 [*Body] 要求的类型。 +* `m` 是类型为 `message` 的值,其中 `b` 为 `bool` 类型的值。 and `F` is a type meeting the requirements of __Fields__. -[table Valid expressions -[[Expression] [Type] [Semantics, Pre/Post-conditions]] +[table 有效表达式 +[[表达式] [类型] [语义、前置条件与后置条件]] [ [`B::value_type`] [] - [ - The return type of the `message::body` member function. - If this is not movable or not copyable, the containing message - will be not movable or not copyable. - ] + [`message::body` 成员函数返回的类型。如果该类型不支持移动或复制,则包含它的消息对象同样不支持移动或复制。] ][ [`B::reader`] [] - [ - If present, indicates that the body can be parsed. The type - must meet the requirements of __BodyReader__. The implementation - constructs an object of this type to obtain buffers into which - parsed body octets are placed. - ] + [若该类型存在,则表示消息体可被解析。该类型必须满足 __BodyReader__ 的要求。实现会构造该类型的对象,用于获取存放已解析消息体八位字节的缓冲区。] ][ [`B::writer`] [] - [ - If present, indicates that the body is serializable. The type - must meet the requirements of __BodyWriter__. The implementation - constructs an object of this type to obtain buffers representing - the message body for serialization. - ] + [若存在该类型,则用于表示该主体可序列化。该类型必须满足 __BodyWriter__ 的要求。该实现用于构造该类型的对象,以获取用于表示消息主体序列化内容的缓冲区。] ][ [ ``` @@ -63,44 +47,25 @@ In this table: ``` ] [`std::uint64_t`] - [ - This static member function is optional. It returns the payload - size of `body` in bytes not including any chunked transfer encoding. - The return value may be zero, to indicate that the message is known - to have no payload. The function shall not exit via an exception. - - When this function is present: - - * The function shall not fail + [该静态成员函数为可选。它返回消息体的大小(以字节为单位),不包含任何分块传输编码。返回值可能为零,表示已知消息不包含有效载荷。该函数不应通过异常退出。 - * A call to - [link beast.ref.boost__beast__http__message.payload_size `message::payload_size`] - will return the same value as `size`. +当该函数存在时: - * A call to - [link beast.ref.boost__beast__http__message.prepare_payload `message::prepare_payload`] - will remove "chunked" from the Transfer-Encoding field if it appears - as the last encoding, and will set the Content-Length field to the - returned value. +* 函数不应失败。 +* 调用 [link beast.ref.boost__beast__http__message.payload_size `message::payload_size`] 将返回与 `size` 相同的值。 +* 调用 [link beast.ref.boost__beast__http__message.prepare_payload `message::prepare_payload`] 将移除 Transfer-Encoding 字段中的 "chunked"(如果它作为最后一个编码出现),并将 Content-Length 字段设置为返回的值。 - Otherwise, when the function is omitted: +否则,当该函数省略时: - * A call to - [link beast.ref.boost__beast__http__message.payload_size `message::payload_size`] - will return `boost::none`. - - * A call to - [link beast.ref.boost__beast__http__message.prepare_payload `message::prepare_payload`] - will erase the Content-Length field, and add "chunked" as the last - encoding in the Transfer-Encoding field if it is not already present. - ] +* 调用 [link beast.ref.boost__beast__http__message.payload_size `message::payload_size`] 将返回 `boost::none`。 +* 调用 [link beast.ref.boost__beast__http__message.prepare_payload `message::prepare_payload`] 将擦除 Content-Length 字段,并在 Transfer-Encoding 字段中添加 "chunked" 作为最后一个编码(如果尚未存在)。] ]] -[heading Exemplar] +[heading 示例] [concept_Body] -[heading Models] +[heading 模型] * [link beast.ref.boost__beast__http__basic_dynamic_body `basic_dynamic_body`] * [link beast.ref.boost__beast__http__basic_file_body `basic_file_body`] From 7edf4cef7e1cbaa8a8081c5a14befd0b7b79d7c7 Mon Sep 17 00:00:00 2001 From: Boost-tran Date: Fri, 26 Jun 2026 20:24:34 +0000 Subject: [PATCH 4/7] Translated using Weblate (Chinese (Simplified Han script)) Currently translated at 100.0% (30 of 30 strings) Translation: Boost Beast Translation (zh_Hans)/Doc / Qbk / 01 Intro / Intro (qbk) Translate-URL: https://insights.cppalliance.org/weblate/projects/boost-beast-documentation-zh_Hans/doc-qbk-01-intro--intro-qbk/zh_Hans/ --- doc/qbk/01_intro/_intro_zh_Hans.qbk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/qbk/01_intro/_intro_zh_Hans.qbk b/doc/qbk/01_intro/_intro_zh_Hans.qbk index 16b90cc..6b44f70 100644 --- a/doc/qbk/01_intro/_intro_zh_Hans.qbk +++ b/doc/qbk/01_intro/_intro_zh_Hans.qbk @@ -36,7 +36,7 @@ Beast 授权用户基于 HTTP/1 和 WebSocket 构建自己的库、客户端及 [section 要求] [important - 该库面向熟悉 Asio 的程序员。用户 + 该库面向熟悉 __Asio__的程序员。用户 wish to use asynchronous interfaces should already know how to create concurrent network programs using callbacks or coroutines. ] From 05079ab156470dec21b9181186dd08e24a371bb1 Mon Sep 17 00:00:00 2001 From: Boost-tran Date: Fri, 26 Jun 2026 20:24:34 +0000 Subject: [PATCH 5/7] Translated using Weblate (Chinese (Simplified Han script)) Currently translated at 100.0% (3 of 3 strings) Translation: Boost Beast Translation (zh_Hans)/Doc / Qbk / 07 Concepts / Buffersequence (qbk) Translate-URL: https://insights.cppalliance.org/weblate/projects/boost-beast-documentation-zh_Hans/doc-qbk-07-concepts-buffersequence-qbk/zh_Hans/ --- doc/qbk/07_concepts/BufferSequence_zh_Hans.qbk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/qbk/07_concepts/BufferSequence_zh_Hans.qbk b/doc/qbk/07_concepts/BufferSequence_zh_Hans.qbk index 86612dd..c54ee02 100644 --- a/doc/qbk/07_concepts/BufferSequence_zh_Hans.qbk +++ b/doc/qbk/07_concepts/BufferSequence_zh_Hans.qbk @@ -7,9 +7,9 @@ Official repository: https://github.com/boostorg/beast ] -[section:BufferSequence BufferSequence] +[section:BufferSequence 缓冲区序列] -A [*BufferSequence] is a type meeting either of the following requirements: +[*缓冲区序列] 是指满足以下任一要求的类型: * __ConstBufferSequence__ * __MutableBufferSequence__ From e17562f597bf8e180bf2a5fa1c2a6183b52065e9 Mon Sep 17 00:00:00 2001 From: Boost-tran Date: Fri, 26 Jun 2026 20:24:34 +0000 Subject: [PATCH 6/7] Translated using Weblate (Chinese (Simplified Han script)) Currently translated at 100.0% (40 of 40 strings) Translation: Boost Beast Translation (zh_Hans)/Doc / Qbk / 07 Concepts / File (qbk) Translate-URL: https://insights.cppalliance.org/weblate/projects/boost-beast-documentation-zh_Hans/doc-qbk-07-concepts-file-qbk/zh_Hans/ --- doc/qbk/07_concepts/File_zh_Hans.qbk | 141 ++++++--------------------- 1 file changed, 29 insertions(+), 112 deletions(-) diff --git a/doc/qbk/07_concepts/File_zh_Hans.qbk b/doc/qbk/07_concepts/File_zh_Hans.qbk index b00ea8c..3ff75b1 100644 --- a/doc/qbk/07_concepts/File_zh_Hans.qbk +++ b/doc/qbk/07_concepts/File_zh_Hans.qbk @@ -5,173 +5,90 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ] -[section:File File] +[section:File 文件] -The [*File] concept abstracts access to files in the underlying file system. -To support other platform interfaces, users may author their own [*File] -types which meet these requirements. +[*File] 概念抽象了对底层文件系统中文件的访问。为了支持其他平台接口,用户可以编写满足这些要求的自有 [*File] 类型。 -[heading Associated Types] +[heading 关联类型] * [link beast.ref.boost__beast__file_mode `file_mode`] * [link beast.ref.boost__beast__is_file `is_file`] -[heading Requirements] +[heading 要求] -In this table: +在下表中: -* `F` is a [*File] type -* `f` is an instance of `F` -* `p` is a value of type `char const*` which points to a null +* `F` 是一个 [*File] 类型。 +* `f` 是 `F` 的一个实例。 +* `p` 是一个 `char const*` 类型的值,指向一个空字符(null) terminated utf-8 encoded string. -* `m` is an instance of [link beast.ref.boost__beast__file_mode `file_mode`] -* `n` is a number of bytes, convertible to `std::size_t` -* `o` is a byte offset in the file, convertible to `std::uint64_t` -* `b` is any non-const pointer to memory -* `c` is any possibly-const pointer to memory -* `ec` is a reference of type [link beast.ref.boost__beast__error_code `error_code`] +* `m` 是一个 [link beast.ref.boost__beast__file_mode `file_mode`] 的实例。 +* `n` 是字节数,可转换为 `std::size_t` 类型。 +* `o` 是文件中的字节偏移量,可转换为 `std::uint64_t` 类型。 +* `b` 是指向内存的任意非常量指针。 +* `c` 是指向内存的任意可能为常量的指针。 +* `ec` 是一个 [link beast.ref.boost__beast__error_code `error_code`] 类型的引用。 -[table Valid expressions -[[Expression] [Type] [Semantics, Pre/Post-conditions]] -[[Operation] [Return Type] [Semantics, Pre/Post-conditions]] +[table 有效表达式 +[[表达式] [类型] [语义,前置/后置条件]] +[[操作] [返回类型] [语义,前置/后置条件]] [ [`F()`] [ ] - [ - Default constructable - ] + [默认构造(Default constructible)] ] [ [`f.~F()`] [ ] - [ - Destructible. - If `f` refers to an open file, it is first closed - as if by a call to `close` with the error ignored. - ] + [可析构。若 `f` 引用一个打开的文件,则先将其关闭,其行为等同于调用 `close`,且忽略可能产生的错误。] ] [ [`f.is_open()`] [`bool`] - [ - Returns `true` if `f` refers to an open file, `false` otherwise. - ] + [若 `f` 引用一个打开的文件,则返回 `true`,否则返回 `false`。] ] [ [`f.close(ec)`] [] - [ - If `f` refers to an open file, this function attempts to - close the file. - Regardless of whether an error occurs or not, a subsequent - call to `f.is_open()` will return `false`. - The function will ensure that `!ec` is `true` if there was - no error or set to the appropriate error code if an error - occurred. - ] + [若 `f` 引用一个打开的文件,此函数将尝试将其关闭。无论关闭过程中是否发生错误,后续对 `f.is_open()` 的调用均会返回 `false`。同时,该函数会根据实际执行情况设置错误代码:若未发生错误,则确保 `!ec` 为 `true`;若发生错误,则将其设置为相应的错误代码。] ] [ [`f.open(p,m,ec)`] [] - [ - Attempts to open the file at the path specified by `p` - with the mode specified by `m`. - Upon success, a subsequent call to `f.is_open()` will - return `true`. - If `f` refers to an open file, it is first closed - as if by a call to `close` with the error ignored. - The function will ensure that `!ec` is `true` if there was - no error or set to the appropriate error code if an error - occurred. - - ] + [该函数尝试以 `m` 指定的模式打开 `p` 指定的路径对应的文件。若 `f` 引用一个打开的文件,则先将其关闭,其行为等同于调用 `close`,且忽略可能产生的错误。若打开成功,后续对 `f.is_open()` 的调用均会返回 `true`。同时,该函数会根据实际执行情况设置错误代码:若未发生错误,则确保 `!ec` 为 `true`;若发生错误,则将其设置为相应的错误代码。] ] [ [`f.size(ec)`] [`std::uint64_t`] - [ - If `f` refers to an open file, this function attempts to - determine the file size and return its value. - If `f` does not refer to an open file, the function will - set `ec` to `errc::invalid_argument` and return 0. - The function will ensure that `!ec` is `true` if there was - no error or set to the appropriate error code if an error - occurred. - ] + [若 `f` 引用一个打开的文件,该函数将尝试获取并返回其文件大小。若 `f` 未引用一个打开的文件,该函数会将 `ec` 设置为 `errc::invalid_argument` 并返回 0。同时,该函数会根据实际执行情况设置错误代码:若未发生错误,则确保 `!ec` 为 `true`;若发生错误,则将其设置为相应的错误代码。] ] [ [`f.pos(ec)`] [`std::uint64_t`] - [ - If `f` refers to an open file, this function attempts to - determine the current file offset and return it. - If `f` does not refer to an open file, the function will - set `ec` to `errc::invalid_argument` and return 0. - The function will ensure that `!ec` is `true` if there was - no error or set to the appropriate error code if an error - occurred. - ] + [若 `f` 引用一个打开的文件,该函数将尝试获取并返回当前文件偏移量。若 `f` 未引用一个打开的文件,该函数会将 `ec` 设置为 `errc::invalid_argument` 并返回 0。同时,该函数会根据实际执行情况设置错误代码:若未发生错误,则确保 `!ec` 为 `true`;若发生错误,则将其设置为相应的错误代码。] ] [ [`f.seek(o,ec)`] [] - [ - Attempts to reposition the current file offset to the value - `o`, which represents a byte offset relative to the beginning - of the file. - If `f` does not refer to an open file, the function will - set `ec` to `errc::invalid_argument` and return immediately. - The function will ensure that `!ec` is `true` if there was - no error or set to the appropriate error code if an error - occurred. - ] + [该函数尝试将当前文件偏移量重新定位到 `o`,该值表示相对于文件起始位置的字节偏移量。若 `f` 未引用一个打开的文件,该函数会将 `ec` 设置为 `errc::invalid_argument` 并立即返回。同时,该函数会根据实际执行情况设置错误代码:若未发生错误,则确保 `!ec` 为 `true`;若发生错误,则将其设置为相应的错误代码。] ] [ [`f.read(b,n,ec)`] [`std::size_t`] - [ - Attempts to read `n` bytes starting at the current file offset - from the open file referred to by `f`. - Bytes read are stored in the memory buffer at address `b` which - must be at least `n` bytes in size. - The function advances the file offset by the amount read, and - returns the number of bytes actually read, which may be less - than `n`. - If `f` does not refer to an open file, the function will - set `ec` to `errc::invalid_argument` and return immediately. - The function will ensure that `!ec` is `true` if there was - no error or set to the appropriate error code if an error - occurred. - If an end-of-file condition is detected prior to reading any - bytes, the function will ensure that `!ec` is `true` and the - return value shall be 0. - ] + [该函数尝试从 `f` 引用的打开文件中,自当前文件偏移量处读取 `n` 个字节。读取的字节将存储到地址 `b` 处的内存缓冲区中,该缓冲区的大小必须至少为 `n` 个字节。该函数会将文件偏移量推进已读取的字节数,并返回实际读取的字节数,该值可能小于 `n`。若 `f` 未引用一个打开的文件,该函数会将 `ec` 设置为 `errc::invalid_argument` 并立即返回。同时,该函数会根据实际执行情况设置错误代码:若未发生错误,则确保 `!ec` 为 `true`;若发生错误,则将其设置为相应的错误代码。若在读取任何字节之前检测到文件结束条件,该函数将确保 `!ec` 为 `true`,且返回值为 0。] ] [ [`f.write(c,n,ec)`] [`std::size_t`] - [ - Attempts to write `n` bytes from the buffer pointed to by `c` to - the current file offset of the open file referred to by `f`. - The memory buffer at `c` must point to storage of at least `n` - bytes meant to be copied to the file. - The function advances the file offset by the amount written, - and returns the number of bytes actually written, which may be - less than `n`. - If `f` does not refer to an open file, the function will - set `ec` to `errc::invalid_argument` and return immediately. - The function will ensure that `!ec` is `true` if there was - no error or set to the appropriate error code if an error - occurred. - ] + [该函数尝试将 `c` 指向的缓冲区中的 `n` 个字节写入 `f` 引用的打开文件的当前文件偏移量处。`c` 处的内存缓冲区必须指向大小至少为 `n` 个字节的存储,用于复制到文件。该函数会将文件偏移量推进已写入的字节数,并返回实际写入的字节数,该值可能小于 `n`。若 `f` 未引用一个打开的文件,该函数会将 `ec` 设置为 `errc::invalid_argument` 并立即返回。同时,该函数会根据实际执行情况设置错误代码:若未发生错误,则确保 `!ec` 为 `true`;若发生错误,则将其设置为相应的错误代码。] ] ] -[heading Exemplar] +[heading 示例] [concept_File] -[heading Models] +[heading 模型] * [link beast.ref.boost__beast__file_posix `file_posix`] * [link beast.ref.boost__beast__file_stdio `file_stdio`] From 895f225a7d11df58f18f62023b367d1d6294a817 Mon Sep 17 00:00:00 2001 From: Boost-tran Date: Fri, 26 Jun 2026 20:24:34 +0000 Subject: [PATCH 7/7] Translated using Weblate (Chinese (Simplified Han script)) Currently translated at 100.0% (31 of 31 strings) Translation: Boost Beast Translation (zh_Hans)/Doc / Qbk / 06 Websocket / 04 Messages (qbk) Translate-URL: https://insights.cppalliance.org/weblate/projects/boost-beast-documentation-zh_Hans/doc-qbk-06-websocket-04-messages-qbk/zh_Hans/ --- doc/qbk/06_websocket/04_messages_zh_Hans.qbk | 86 +++++++------------- 1 file changed, 28 insertions(+), 58 deletions(-) diff --git a/doc/qbk/06_websocket/04_messages_zh_Hans.qbk b/doc/qbk/06_websocket/04_messages_zh_Hans.qbk index e5bc49a..cde94be 100644 --- a/doc/qbk/06_websocket/04_messages_zh_Hans.qbk +++ b/doc/qbk/06_websocket/04_messages_zh_Hans.qbk @@ -9,93 +9,65 @@ [/-----------------------------------------------------------------------------] -[section:messages Messages] - -Once a websocket session is established, messages can be sent unsolicited by -either peer at any time. A message is made up of one or more ['messages frames]. -Each frame is prefixed with the size of the payload in bytes, followed by the -data. A frame also contains a flag (called 'fin') indicating whether or not it -is the last frame of the message. When a message is made up from only one frame, -it is possible to know immediately what the size of the message will be. -Otherwise, the total size of the message can only be determined once -the last frame is received. - -The boundaries between frames of a multi-frame message are not not considered -part of the message. Intermediaries such as proxies which forward the websocket -traffic are free to "reframe" (split frames and combine them) the message in -arbitrary ways. These intermediaries include Beast, which can reframe messages -automatically in some cases depending on the options set on the stream. +[section:messages 消息] + +WebSocket 会话建立后,任何一端都可以随时主动发送消息。每条消息由一个或多个消息帧组成。每个帧的前部是有效载荷的字节长度,随后是数据内容。帧还包含一个名为 fin 的标志,用于标识该帧是否为消息的最后一帧。如果消息只由一个帧构成,则可以立即获知消息大小。否则,消息的总大小只能在接收到最后一帧时才能确定。 + +多帧消息中,各帧的边界不属于消息内容的一部分。像代理这类转发 WebSocket 流量的中间节点,可以自由地对消息进行“重帧处理”(即拆分或合并帧)。Beast 也属于这类中间节点,它会根据流上配置的选项,在某些场景下自动重帧消息。 [caution - An algorithm should never depend on the way that incoming or outgoing + 算法不应依赖入站或出站消息的帧结构方式。 messages are split up into frames. ] -Messages can be either text or binary. A message sent as text must contain -consist of valid utf8, while a message sent as binary may contain arbitrary -data. In addition to message frames, websocket provides ['control frames] -in the form of ping, pong, and close messages which have a small upper limit -on their payload size. Depending on how a message is framed, control frames -may have more opportunities to be sent in-between. +消息可以是文本类型或二进制类型。以文本形式发送的消息必须包含有效的 UTF-8 编码,而以二进制形式发送的消息则可以包含任意数据。除了消息帧之外,WebSocket 还提供控制帧,包括 ping、pong 和 close 消息,这些控制帧的有效载荷大小有较小的上限限制。根据消息的帧结构方式,控制帧可能有更多的机会在传输间隙发送。 -[heading Sending] +[heading 发送] -These stream members are used to write websocket messages: +以下流成员函数用于写入 WebSocket 消息: -[table WebSocket Stream Write Operations -[[Function][Description]] +[table WebSocket 流写入操作 +[[函数][描述]] [ [ [link beast.ref.boost__beast__websocket__stream.write.overload2 `write`], [link beast.ref.boost__beast__websocket__stream.async_write `async_write`] - ][ - Send a buffer sequence as a complete message. - ] + ][将缓冲区序列作为完整消息发送。] ][ [ [link beast.ref.boost__beast__websocket__stream.write_some.overload2 `write_some`], [link beast.ref.boost__beast__websocket__stream.async_write_some `async_write_some`] - ][ - Send a buffer sequence as part of a message. - ] + ][将缓冲区序列作为消息的一部分发送。] ]] -This example shows how to send a buffer sequence as a complete message. +本示例展示如何将缓冲区序列作为完整消息发送。 [code_websocket_4_1] -The same message could be sent in two or more frames thusly. +同一消息也可以通过两个或多个帧来发送,如下所示: -[heading Receiving] +[heading 接受] -[table WebSocket Stream Read Operations -[[Function][Description]] +[table WebSocket 流读取操作 +[[函数][描述]] [ [ [link beast.ref.boost__beast__websocket__stream.read.overload2 `read`], [link beast.ref.boost__beast__websocket__stream.async_read `async_read`] - ][ - Read a complete message into a __DynamicBuffer__. - ] + ][将完整消息读入 __DynamicBuffer__。] ][ [ [link beast.ref.boost__beast__websocket__stream.read_some.overload2 `read_some`], [link beast.ref.boost__beast__websocket__stream.async_read_some.overload1 `async_read_some`] - ][ - Read part of a message into a __DynamicBuffer__. - ] + ][将消息的部分内容读入 __DynamicBuffer__。] ][ [ [link beast.ref.boost__beast__websocket__stream.read_some.overload4 `read_some`], [link beast.ref.boost__beast__websocket__stream.async_read_some.overload2 `async_read_some`] - ][ - Read part of a message into a __MutableBufferSequence__. - ] + ][将消息的部分内容读入 MutableBufferSequence。] ]] -After the WebSocket handshake is accomplished, callers may send and receive -messages using the message oriented interface. This interface requires that -all of the buffers representing the message are known ahead of time: +完成 WebSocket 握手后,调用方可以使用面向消息的接口收发消息。该接口要求表示消息的所有缓冲区必须事先已知: [code_websocket_4_2] @@ -105,17 +77,15 @@ all of the buffers representing the message are known ahead of time: all be made from the same implicit or explicit strand. ] -[heading Frames] +[heading 消息帧] -Some use-cases make it impractical or impossible to buffer the entire -message ahead of time: +某些场景下,提前将整个消息缓冲起来并不现实或不可行: -* Streaming multimedia to an endpoint. -* Sending a message that does not fit in memory at once. -* Providing incremental results as they become available. +* 将流式多媒体数据发送到终端。 +* 发送无法一次性装入内存的消息。 +* 在结果可用时逐步提供。 -For these cases, the partial data oriented interface may be used. This -example reads and echoes a complete message using this interface: +在这些情况下,可以使用面向部分数据的接口。以下示例使用该接口读取并回显完整消息: [code_websocket_4_3]