Loading…
|
Translation changed |
|
|
String added in the repository |
|
Loading…
|
Translation changed |
|
|
String added in the repository |
|
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:通常,在非平凡的 HTTP 应用程序中,我们希望在为 [*Body] 选择类型之前,先读取 HTTP 头部并检查其内容。为了实现这一点,需要有一种方法来对消息的头部部分进行建模。并且,我们希望以这样的方式来实现:让那些将头部作为参数的函数,也能够接受代表整个消息的类型(函数只会看到头部部分)。这表明可以通过从 message 中分离出一个新的基类来使用继承:``` /// An HTTP message header template<bool isRequest, class Fields> struct header; ```