-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHttpMessage
More file actions
59 lines (46 loc) · 1.18 KB
/
HttpMessage
File metadata and controls
59 lines (46 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Copyright (C) 2021 Frank Mertens.
*
* Distribution and use is allowed under the terms of the GNU General Public License version 3
* (see CoreComponents/LICENSE-gpl-3.0).
*
*/
#pragma once
#include <cc/HttpStatus>
#include <cc/Stream>
#include <cc/Map>
namespace cc {
/** \class HttpMessage cc/HttpMessage
* \ingroup http_protocol
* \brief HTTP message
*/
class HttpMessage: public Object
{
public:
/** Create a null HTTP message
*/
HttpMessage() = default;
/** Message header
*/
const Map<String> &header() const { return me().header_; }
/** %Get message header value by \a name
*/
String header(const String &name) const { return me().header_(name); }
/** %Payload stream
*/
Stream payload() const { return me().payload_; }
protected:
friend class HttpMessageParser;
struct State: public Object::State
{
Map<String> header_;
Stream payload_;
};
HttpMessage(State *newState):
Object{newState}
{}
State *operator->() { return &me(); }
State &me() { return Object::me.as<State>(); }
const State &me() const { return Object::me.as<State>(); }
};
} // namespace cc