GCC Code Coverage Report


Directory: libs/http_proto/
File: boost/http_proto/message_base.hpp
Date: 2024-03-08 19:26:15
Exec Total Coverage
Lines: 9 9 100.0%
Functions: 3 3 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 BOOST_SYMBOL_VISIBLE
25 message_base
26 : public fields_base
27 , public message_view_base
28 {
29 friend class request;
30 friend class response;
31
32 explicit
33 81 message_base(
34 detail::kind k) noexcept
35 : fields_view_base(
36 &this->fields_base::h_)
37 81 , fields_base(k)
38 {
39 81 }
40
41 284 message_base(
42 detail::kind k,
43 core::string_view s)
44 : fields_view_base(
45 &this->fields_base::h_)
46 284 , fields_base(k, s)
47 {
48 284 }
49
50 explicit
51 8 message_base(
52 detail::header const& ph) noexcept
53 : fields_view_base(
54 &this->fields_base::h_)
55 8 , fields_base(ph)
56 {
57 8 }
58
59 public:
60 //--------------------------------------------
61 //
62 // Metadata
63 //
64 //--------------------------------------------
65
66 /** Set the payload size
67 */
68 BOOST_HTTP_PROTO_DECL
69 void
70 set_payload_size(
71 std::uint64_t n);
72
73 /** Set the Content-Length to the specified value
74 */
75 BOOST_HTTP_PROTO_DECL
76 void
77 set_content_length(
78 std::uint64_t n);
79
80 /** Set whether the payload is chunked.
81 */
82 BOOST_HTTP_PROTO_DECL
83 void
84 set_chunked(bool value);
85
86 /** Set whether the connection should stay open.
87
88 Even when keep-alive is set to true, the
89 semantics of the other header fields may
90 require the connection to be closed. For
91 example when there is no content length
92 specified in a response.
93 */
94 BOOST_HTTP_PROTO_DECL
95 void
96 set_keep_alive(bool value);
97 };
98
99 } // http_proto
100 } // boost
101
102 #endif
103