Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com) |
3 |
|
|
// Copyright (c) 2024 Christian Mazakas |
4 |
|
|
// |
5 |
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying |
6 |
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
7 |
|
|
// |
8 |
|
|
// Official repository: https://github.com/cppalliance/http_proto |
9 |
|
|
// |
10 |
|
|
|
11 |
|
|
#ifndef BOOST_HTTP_PROTO_MESSAGE_BASE_HPP |
12 |
|
|
#define BOOST_HTTP_PROTO_MESSAGE_BASE_HPP |
13 |
|
|
|
14 |
|
|
#include <boost/http_proto/detail/config.hpp> |
15 |
|
|
#include <boost/http_proto/fields_base.hpp> |
16 |
|
|
#include <boost/http_proto/message_view_base.hpp> |
17 |
|
|
#include <boost/core/detail/string_view.hpp> |
18 |
|
|
|
19 |
|
|
namespace boost { |
20 |
|
|
namespace http_proto { |
21 |
|
|
|
22 |
|
|
/** Provides message metadata for requests and responses |
23 |
|
|
*/ |
24 |
|
|
class message_base |
25 |
|
|
: public fields_base |
26 |
|
|
, public message_view_base |
27 |
|
|
{ |
28 |
|
|
friend class request; |
29 |
|
|
friend class response; |
30 |
|
|
|
31 |
|
|
explicit |
32 |
|
133 |
message_base( |
33 |
|
|
detail::kind k) noexcept |
34 |
|
|
: fields_view_base( |
35 |
|
|
&this->fields_base::h_) |
36 |
|
133 |
, fields_base(k) |
37 |
|
|
{ |
38 |
|
133 |
} |
39 |
|
|
|
40 |
|
8 |
message_base( |
41 |
|
|
detail::kind k, |
42 |
|
|
std::size_t storage_size) |
43 |
|
|
: fields_view_base( |
44 |
|
|
&this->fields_base::h_) |
45 |
|
|
, fields_base( |
46 |
|
8 |
k, storage_size) |
47 |
|
|
{ |
48 |
|
8 |
} |
49 |
|
|
|
50 |
|
20 |
message_base( |
51 |
|
|
detail::kind k, |
52 |
|
|
std::size_t storage_size, |
53 |
|
|
std::size_t max_storage_size) |
54 |
|
|
: fields_view_base( |
55 |
|
|
&this->fields_base::h_) |
56 |
|
|
, fields_base( |
57 |
|
20 |
k, storage_size, max_storage_size) |
58 |
|
|
{ |
59 |
|
12 |
} |
60 |
|
|
|
61 |
|
293 |
message_base( |
62 |
|
|
detail::kind k, |
63 |
|
|
core::string_view s) |
64 |
|
|
: fields_view_base( |
65 |
|
|
&this->fields_base::h_) |
66 |
|
293 |
, fields_base(k, s) |
67 |
|
|
{ |
68 |
|
291 |
} |
69 |
|
|
|
70 |
|
|
explicit |
71 |
|
8 |
message_base( |
72 |
|
|
detail::header const& ph) noexcept |
73 |
|
|
: fields_view_base( |
74 |
|
|
&this->fields_base::h_) |
75 |
|
8 |
, fields_base(ph) |
76 |
|
|
{ |
77 |
|
8 |
} |
78 |
|
|
|
79 |
|
|
public: |
80 |
|
|
//-------------------------------------------- |
81 |
|
|
// |
82 |
|
|
// Metadata |
83 |
|
|
// |
84 |
|
|
//-------------------------------------------- |
85 |
|
|
|
86 |
|
|
/** Set the payload size |
87 |
|
|
*/ |
88 |
|
|
BOOST_HTTP_PROTO_DECL |
89 |
|
|
void |
90 |
|
|
set_payload_size( |
91 |
|
|
std::uint64_t n); |
92 |
|
|
|
93 |
|
|
/** Set the Content-Length to the specified value |
94 |
|
|
*/ |
95 |
|
|
BOOST_HTTP_PROTO_DECL |
96 |
|
|
void |
97 |
|
|
set_content_length( |
98 |
|
|
std::uint64_t n); |
99 |
|
|
|
100 |
|
|
/** Set whether the payload is chunked. |
101 |
|
|
*/ |
102 |
|
|
BOOST_HTTP_PROTO_DECL |
103 |
|
|
void |
104 |
|
|
set_chunked(bool value); |
105 |
|
|
|
106 |
|
|
/** Set whether the connection should stay open. |
107 |
|
|
|
108 |
|
|
Even when keep-alive is set to true, the |
109 |
|
|
semantics of the other header fields may |
110 |
|
|
require the connection to be closed. For |
111 |
|
|
example when there is no content length |
112 |
|
|
specified in a response. |
113 |
|
|
*/ |
114 |
|
|
BOOST_HTTP_PROTO_DECL |
115 |
|
|
void |
116 |
|
|
set_keep_alive(bool value); |
117 |
|
|
}; |
118 |
|
|
|
119 |
|
|
} // http_proto |
120 |
|
|
} // boost |
121 |
|
|
|
122 |
|
|
#endif |
123 |
|
|
|