95.65% Lines (22/23)
100.00% Functions (3/3)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2026 Vinnie Falco (vinnie.falco@gmail.com) | 2 | // Copyright (c) 2026 Vinnie Falco (vinnie.falco@gmail.com) | |||||
| 3 | // | 3 | // | |||||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 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) | 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 6 | // | 6 | // | |||||
| 7 | // Official repository: https://github.com/cppalliance/http | 7 | // Official repository: https://github.com/cppalliance/http | |||||
| 8 | // | 8 | // | |||||
| 9 | 9 | |||||||
| 10 | #include <boost/http/config.hpp> | 10 | #include <boost/http/config.hpp> | |||||
| 11 | #include <boost/http/detail/except.hpp> | 11 | #include <boost/http/detail/except.hpp> | |||||
| 12 | #include <boost/http/detail/header.hpp> | 12 | #include <boost/http/detail/header.hpp> | |||||
| 13 | 13 | |||||||
| 14 | #include <cstdint> | 14 | #include <cstdint> | |||||
| 15 | #include <memory> | 15 | #include <memory> | |||||
| 16 | 16 | |||||||
| 17 | namespace boost { | 17 | namespace boost { | |||||
| 18 | namespace http { | 18 | namespace http { | |||||
| 19 | 19 | |||||||
| 20 | std::size_t | 20 | std::size_t | |||||
| HITCBC | 21 | 83712 | parser_config_impl:: | 21 | 83738 | parser_config_impl:: | ||
| 22 | max_overread() const noexcept | 22 | max_overread() const noexcept | |||||
| 23 | { | 23 | { | |||||
| HITCBC | 24 | 83712 | return headers.max_size + min_buffer; | 24 | 83738 | return headers.max_size + min_buffer; | ||
| 25 | } | 25 | } | |||||
| 26 | 26 | |||||||
| 27 | std::shared_ptr<parser_config_impl const> | 27 | std::shared_ptr<parser_config_impl const> | |||||
| HITCBC | 28 | 113 | make_parser_config(parser_config cfg) | 28 | 115 | make_parser_config(parser_config cfg) | ||
| 29 | { | 29 | { | |||||
| HITCBC | 30 | 113 | if(cfg.max_prepare < 1) | 30 | 115 | if(cfg.max_prepare < 1) | ||
| MISUBC | 31 | ✗ | detail::throw_invalid_argument(); | 31 | ✗ | detail::throw_invalid_argument(); | ||
| 32 | 32 | |||||||
| HITCBC | 33 | 113 | auto impl = std::make_shared<parser_config_impl>(std::move(cfg)); | 33 | 115 | auto impl = std::make_shared<parser_config_impl>(std::move(cfg)); | ||
| 34 | 34 | |||||||
| 35 | /* | 35 | /* | |||||
| 36 | | fb | cb0 | cb1 | T | f | | 36 | | fb | cb0 | cb1 | T | f | | |||||
| 37 | 37 | |||||||
| 38 | fb flat_dynamic_buffer headers.max_size | 38 | fb flat_dynamic_buffer headers.max_size | |||||
| 39 | cb0 circular_buffer min_buffer | 39 | cb0 circular_buffer min_buffer | |||||
| 40 | cb1 circular_buffer min_buffer | 40 | cb1 circular_buffer min_buffer | |||||
| 41 | f table max_table_space | 41 | f table max_table_space | |||||
| 42 | */ | 42 | */ | |||||
| 43 | 43 | |||||||
| HITCBC | 44 | 113 | std::size_t space_needed = 0; | 44 | 115 | std::size_t space_needed = 0; | ||
| 45 | 45 | |||||||
| HITCBC | 46 | 113 | space_needed += impl->headers.valid_space_needed(); | 46 | 115 | space_needed += impl->headers.valid_space_needed(); | ||
| 47 | 47 | |||||||
| 48 | // cb0_, cb1_ | 48 | // cb0_, cb1_ | |||||
| HITCBC | 49 | 113 | space_needed += impl->min_buffer + impl->min_buffer; | 49 | 115 | space_needed += impl->min_buffer + impl->min_buffer; | ||
| 50 | 50 | |||||||
| 51 | // round up to alignof(detail::header::entry) | 51 | // round up to alignof(detail::header::entry) | |||||
| HITCBC | 52 | 113 | auto const al = alignof(detail::header::entry); | 52 | 115 | auto const al = alignof(detail::header::entry); | ||
| HITCBC | 53 | 113 | space_needed = al * ((space_needed + al - 1) / al); | 53 | 115 | space_needed = al * ((space_needed + al - 1) / al); | ||
| 54 | 54 | |||||||
| HITCBC | 55 | 113 | impl->space_needed = space_needed; | 55 | 115 | impl->space_needed = space_needed; | ||
| HITCBC | 56 | 113 | impl->max_codec = 0; // not currently used for parser | 56 | 115 | impl->max_codec = 0; // not currently used for parser | ||
| 57 | 57 | |||||||
| HITCBC | 58 | 226 | return impl; | 58 | 230 | return impl; | ||
| HITCBC | 59 | 113 | } | 59 | 115 | } | ||
| 60 | 60 | |||||||
| 61 | std::shared_ptr<serializer_config_impl const> | 61 | std::shared_ptr<serializer_config_impl const> | |||||
| HITCBC | 62 | 2 | make_serializer_config(serializer_config cfg) | 62 | 2 | make_serializer_config(serializer_config cfg) | ||
| 63 | { | 63 | { | |||||
| HITCBC | 64 | 2 | auto impl = std::make_shared<serializer_config_impl>(); | 64 | 2 | auto impl = std::make_shared<serializer_config_impl>(); | ||
| HITCBC | 65 | 2 | static_cast<serializer_config&>(*impl) = std::move(cfg); | 65 | 2 | static_cast<serializer_config&>(*impl) = std::move(cfg); | ||
| 66 | 66 | |||||||
| HITCBC | 67 | 2 | std::size_t space_needed = 0; | 67 | 2 | std::size_t space_needed = 0; | ||
| HITCBC | 68 | 2 | space_needed += impl->payload_buffer; | 68 | 2 | space_needed += impl->payload_buffer; | ||
| 69 | 69 | |||||||
| HITCBC | 70 | 2 | impl->space_needed = space_needed; | 70 | 2 | impl->space_needed = space_needed; | ||
| 71 | 71 | |||||||
| HITCBC | 72 | 4 | return impl; | 72 | 4 | return impl; | ||
| HITCBC | 73 | 2 | } | 73 | 2 | } | ||
| 74 | 74 | |||||||
| 75 | } // http | 75 | } // http | |||||
| 76 | } // boost | 76 | } // boost | |||||