Loading…
|
Translation changed |
|
|
String added in the repository |
|
Loading…
|
Translation changed |
|
|
String added in the repository |
|
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.高级服务器可能希望等到获取头部信息后,再决定使用哪种 Body 模板类型。这样就能根据头部内容(例如请求方法、目标路径或查询参数)来选用合适的消息体类型。具体做法是:先使用一个简单的消息体类型(如 [link beast.ref.boost__beast__http__empty_body `empty_body`])声明解析器,只用于读取头部。然后,基于这个已有的解析器构造一个新的解析器,并根据头部或其他信息来确定新解析器的消息体类型。