GCC Code Coverage Report


Directory: libs/http_proto/
File: boost/http_proto/message_base.hpp
Date: 2024-03-18 23:12:48
Exec Total Coverage
Lines: 12 12 100.0%
Functions: 4 4 100.0%
Branches: 0 0 -%

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 83 message_base(
33 detail::kind k) noexcept
34 : fields_view_base(
35 &this->fields_base::h_)
36 83 , fields_base(k)
37 {
38 83 }
39
40 18 message_base(
41 detail::kind k,
42 std::size_t initial_size,
43 std::size_t max_capacity)
44 : fields_view_base(
45 &this->fields_base::h_)
46 , fields_base(
47 18 k, initial_size, max_capacity)
48 {
49 18 }
50
51 288 message_base(
52 detail::kind k,
53 core::string_view s)
54 : fields_view_base(
55 &this->fields_base::h_)
56 288 , fields_base(k, s)
57 {
58 286 }
59
60 explicit
61 8 message_base(
62 detail::header const& ph) noexcept
63 : fields_view_base(
64 &this->fields_base::h_)
65 8 , fields_base(ph)
66 {
67 8 }
68
69 public:
70 //--------------------------------------------
71 //
72 // Metadata
73 //
74 //--------------------------------------------
75
76 /** Set the payload size
77 */
78 BOOST_HTTP_PROTO_DECL
79 void
80 set_payload_size(
81 std::uint64_t n);
82
83 /** Set the Content-Length to the specified value
84 */
85 BOOST_HTTP_PROTO_DECL
86 void
87 set_content_length(
88 std::uint64_t n);
89
90 /** Set whether the payload is chunked.
91 */
92 BOOST_HTTP_PROTO_DECL
93 void
94 set_chunked(bool value);
95
96 /** Set whether the connection should stay open.
97
98 Even when keep-alive is set to true, the
99 semantics of the other header fields may
100 require the connection to be closed. For
101 example when there is no content length
102 specified in a response.
103 */
104 BOOST_HTTP_PROTO_DECL
105 void
106 set_keep_alive(bool value);
107 };
108
109 } // http_proto
110 } // boost
111
112 #endif
113