GCC Code Coverage Report


Directory: libs/http_proto/include/boost/http_proto/
File: boost/http_proto/impl/header_limits.ipp
Date: 2023-02-21 17:23:31
Exec Total Coverage
Lines: 5 5 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //
2 // Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.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_HEADER_LIMITS_IPP
11 #define BOOST_HTTP_PROTO_IMPL_HEADER_LIMITS_IPP
12
13 #include <boost/http_proto/header_limits.hpp>
14 #include <boost/http_proto/detail/except.hpp>
15 #include <boost/http_proto/detail/header.hpp>
16
17 namespace boost {
18 namespace http_proto {
19
20 std::size_t
21 6 header_limits::
22 valid_space_needed() const
23 {
24 /*
25 // "HTTP/1.1 200 OK\r\n\r\n" = 19
26 // "X / HTTP/1.1\r\n" = 14
27 // "HTTP/1.1 200\r\n" = 14
28 // "X:\r\n" = 4
29
30 // make sure `size` is big enough
31 // to hold the largest default buffer:
32 //if( max_size < 19)
33 //max_size = 19;
34
35 // max_size too small
36 if( max_size < 19)
37 detail::throw_invalid_argument();
38
39 // max_size too large
40 if( max_size >
41 BOOST_HTTP_PROTO_MAX_HEADER)
42 detail::throw_invalid_argument();
43
44 // max_start_line too small
45 if( max_start_line < 14)
46 detail::throw_invalid_argument();
47
48 // max_start_line too large
49 if( max_start_line >
50 max_size - 2)
51 detail::throw_invalid_argument();
52
53 // max_field too small
54 if( max_field < 4)
55 detail::throw_invalid_argument();
56
57 // max_field too large
58 if( max_field >
59 max_size)
60 detail::throw_invalid_argument();
61
62 // max_fields too large
63 if( max_fields >
64 max_size / 4)
65 detail::throw_invalid_argument();
66 */
67 static constexpr auto Align =
68 alignof(detail::header::entry);
69 // round up to alignof(A)
70 6 return Align * (
71 6 (max_size + Align - 1) / Align) + (
72 6 max_fields * sizeof(
73 6 detail::header::entry));
74 }
75
76 } // http_proto
77 } // boost
78
79 #endif
80