GCC Code Coverage Report


Directory: libs/http_proto/include/boost/http_proto/
File: boost/http_proto/impl/response.ipp
Date: 2023-01-09 16:11:13
Exec Total Coverage
Lines: 28 50 56.0%
Functions: 2 7 28.6%
Branches: 3 12 25.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2021 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/CPPAlliance/http_proto
8 //
9
10 #ifndef BOOST_HTTP_PROTO_IMPL_RESPONSE_IPP
11 #define BOOST_HTTP_PROTO_IMPL_RESPONSE_IPP
12
13 #include <boost/http_proto/response.hpp>
14 #include <boost/http_proto/response_view.hpp>
15 #include <boost/http_proto/detail/copied_strings.hpp>
16 #include <utility>
17
18 namespace boost {
19 namespace http_proto {
20
21 136 response::
22 136 response() noexcept
23 : fields_view_base(
24 136 &this->fields_base::h_)
25 , message_base(
26 136 detail::kind::response)
27 {
28 }
29
30 response::
31 response(
32 response&& other) noexcept
33 : response()
34 {
35 swap(other);
36 }
37
38 response::
39 response(
40 response const& other)
41 : fields_view_base(
42 &this->fields_base::h_)
43 , message_base(*other.ph_)
44 {
45 }
46
47 response::
48 response(
49 response_view const& other)
50 : fields_view_base(
51 &this->fields_base::h_)
52 , message_base(*other.ph_)
53 {
54 }
55
56 response&
57 response::
58 operator=(
59 response&& other) noexcept
60 {
61 response temp(
62 std::move(other));
63 temp.swap(*this);
64 return *this;
65 }
66
67 response::
68 response(
69 http_proto::status sc,
70 http_proto::version v)
71 : response()
72 {
73 if( sc != h_.res.status ||
74 v != h_.version)
75 set_start_line(sc, v);
76 }
77
78 //------------------------------------------------
79
80 void
81 66 response::
82 set_impl(
83 http_proto::status sc,
84 unsigned short si,
85 string_view rs,
86 http_proto::version v)
87 {
88 // measure and resize
89 66 auto const vs = to_string(v);
90 auto const n =
91 66 vs.size() + 1 +
92 66 3 + 1 +
93 66 rs.size() +
94 66 2;
95
1/2
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
66 auto dest = set_prefix_impl(n);
96
97 66 h_.version = v;
98
1/2
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
66 vs.copy(dest, vs.size());
99 66 dest += vs.size();
100 66 *dest++ = ' ';
101
102 66 h_.res.status = sc;
103 66 h_.res.status_int = si;
104 66 dest[0] = '0' + ((h_.res.status_int / 100) % 10);
105 66 dest[1] = '0' + ((h_.res.status_int / 10) % 10);
106 66 dest[2] = '0' + ((h_.res.status_int / 1) % 10);
107 66 dest[3] = ' ';
108 66 dest += 4;
109
110
1/2
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
66 rs.copy(dest, rs.size());
111 66 dest += rs.size();
112 66 dest[0] = '\r';
113 66 dest[1] = '\n';
114
115 66 h_.on_start_line();
116 66 }
117
118 } // http_proto
119 } // boost
120
121 #endif
122