GCC Code Coverage Report


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