en	Parser Stream Operations
zh-hans	解析器流操作

en	Non-trivial algorithms need to do more than receive entire messages at once, such as:
zh-hans	非平凡算法需要执行的操作不仅限于一次性接收完整消息，该算法需要做更多事，例如：

en	* Receive the header first and body later.
zh-hans	* 先接收头部，再接收消息体。

en	* Receive a large body using a fixed-size buffer.
zh-hans	* 使用固定大小缓冲区接收大型消息体。

en	* Receive a message incrementally: bounded work in each I/O cycle.
zh-hans	* 逐步接收消息：每个 I/O 周期内只处理有限的数据量。

en	* Defer the commitment to a __Body__ type until after reading the header.
zh-hans	* 在读取头部之后，再确定 __Body__ 类型。

en	These types of operations require callers to manage the lifetime of associated state, by constructing a class derived from __basic_parser__. Beast comes with the derived instance __parser__ which creates complete __message__ objects using the __basic_fields__ Fields container.
zh-hans	这类操作要求调用方管理相关状态的生命周期，具体方式为构造一个派生自 __basic_parser__ 的类。Beast 提供派生类 __parser__，该类型使用 __basic_fields__ 字段容器来创建完整的 __message__ 对象。

en	Parser
zh-hans	解析器

en	Name
zh-hans	名称

en	Description
zh-hans	描述

en	__parser__
zh-hans	__解析器__

en	/// An HTTP/1 parser for producing a message. template< bool isRequest, // `true` to parse an HTTP request class Body, // The Body type for the resulting message class Allocator = std::allocator<char>> // The type of allocator for the header class parser : public basic_parser<...>;
zh-hans	/// 用于生成消息的 HTTP/1 解析器 template< bool isRequest, // 若为 true 则解析 HTTP 请求 class Body, // 结果消息的消息体 class Allocator = std::allocator<char>> // 头部所使用的分配器 class parser : public basic_parser<...>;

en	[link beast.ref.boost__beast__http__request_parser `request_parser`]

en	/// An HTTP/1 parser for producing a request message. template<class Body, class Allocator = std::allocator<char>> using request_parser = parser<true, Body, Allocator>;
zh-hans	/// 用于生成请求消息的 HTTP/1 解析器 template<class Body, class Allocator = std::allocator<char>> using request_parser = parser<true, Body, Allocator>;

en	[link beast.ref.boost__beast__http__response_parser `response_parser`]

en	/// An HTTP/1 parser for producing a response message. template<class Body, class Allocator = std::allocator<char>> using response_parser = parser<false, Body, Allocator>;
zh-hans	/// 用于生成响应消息的 HTTP/1 解析器 template<class Body, class Allocator = std::allocator<char>> using response_parser = parser<false, Body, Allocator>;

en	The __basic_parser__ and classes derived from it handle octet streams
zh-hans	__basic_parser__ 及其派生类用于处理八位字节流。

en	The stream operations which work on parsers are:
zh-hans	用于操作解析器的流操作如下：

en	Parser Stream Operations
zh-hans	解析器流操作

en	Name
zh-hans	名称

en	Description
zh-hans	描述

en	[link beast.ref.boost__beast__http__read.overload1 [*read]]

en	Read everything into a parser from a __SyncReadStream__.
zh-hans	从 __SyncReadStream__ 读取所有数据到解析器。

en	[link beast.ref.boost__beast__http__async_read.overload1 [*async_read]]

en	Read everything into a parser asynchronously from an __AsyncReadStream__.
zh-hans	从 __AsyncReadStream__ 异步读取所有数据到解析器。

en	[link beast.ref.boost__beast__http__read_header.overload1 [*read_header]]

en	Read only the header octets into a parser from a __SyncReadStream__.
zh-hans	从 __SyncReadStream__ 仅读取头部八位字节到解析器。

en	[link beast.ref.boost__beast__http__async_read_header [*async_read_header]]

en	Read only the header octets into a parser asynchronously from an __AsyncReadStream__.
zh-hans	从 __AsyncReadStream__ 异步仅读取头部八位字节到解析器。

en	[link beast.ref.boost__beast__http__read_some.overload1 [*read_some]]

en	Read some octets into a parser from a __SyncReadStream__.
zh-hans	从 __SyncReadStream__ 读取部分八位字节到解析器。

en	[link beast.ref.boost__beast__http__async_read_some [*async_read_some]]

en	Read some octets into a parser asynchronously from an __AsyncReadStream__.
zh-hans	从 __AsyncReadStream__ 异步读取部分八位字节到解析器。

en	As with message stream operations, parser stream operations require a persisted __DynamicBuffer__ for holding unused octets from the stream. The basic parser implementation is optimized for the case where this dynamic buffer stores its input sequence in a single contiguous memory buffer. It is advised to use an instance of __flat_buffer__, __flat_static_buffer__, or __flat_static_buffer_base__ for this purpose, although a user defined instance of __DynamicBuffer__ which produces input sequences of length one is also suitable.
zh-hans	与消息流操作类似，解析器流操作也需要一个持久的 DynamicBuffer 来保存流中未使用的八位字节。当动态缓冲区使用单个连续内存块存储输入序列时，基本解析器实现能达到最优性能。因此，建议使用 flat_buffer、flat_static_buffer 或 flat_static_buffer_base 的实例；当然，用户自定义的 DynamicBuffer 实现，只要它能生成长度为 1 的输入序列，也同样适用。

en	The parser contains a message constructed internally. Arguments passed to the parser's constructor are forwarded into the message container. The caller can access the message inside the parser by calling [link beast.ref.boost__beast__http__parser.get `parser::get`]. If the `Fields` and `Body` types are [*MoveConstructible], the caller can take ownership of the message by calling [link beast.ref.boost__beast__http__parser.release `parser::release`]. In this example we read an HTTP response with a string body using a parser, then print the response:
zh-hans	解析器内部包含一个已构造的消息对象。传入解析器构造函数的参数会转发到消息容器中。调用方可通过 [link beast.ref.boost__beast__http__parser.get `parser::get`] 访问该消息。若 `Fields` 和 `Body` 类型支持移动构造，调用方还可通过 [link beast.ref.boost__beast__http__parser.release `parser::release`] 获取消息的所有权。以下示例使用解析器读取一个包含字符串消息体的 HTTP 响应，并将其打印出来：

en	Incremental Read __example__
zh-hans	增量读取 __示例__

en	This function uses [link beast.ref.boost__beast__http__buffer_body `buffer_body`] and parser stream operations to read a message body progressively using a small, fixed-size buffer:
zh-hans	该函数使用 [link beast.ref.boost__beast__http__buffer_body `buffer_body`] 和解析器流操作，通过一个固定大小的小缓冲区逐步读取消息体：

en	Reading large response body __example__
zh-hans	读取大型响应消息体 __示例__

en	This example presents how to increase the default limit of the response body size, thus the content larger than the default 8MB can be read.
zh-hans	本示例展示如何提高响应消息体大小的默认限制，以便读取超过默认 8MB 大小的内容。