LCOV - code coverage report
Current view: top level - libs/http/src - config.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 96.0 % 25 24
Test Date: 2026-02-02 17:02:49 Functions: 100.0 % 3 3

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2026 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
       8              : //
       9              : 
      10              : #include <boost/http/config.hpp>
      11              : #include <boost/http/detail/except.hpp>
      12              : #include <boost/http/detail/header.hpp>
      13              : 
      14              : #include <cstdint>
      15              : #include <memory>
      16              : 
      17              : namespace boost {
      18              : namespace http {
      19              : 
      20              : std::size_t
      21        73535 : parser_config_impl::
      22              : max_overread() const noexcept
      23              : {
      24        73535 :     return headers.max_size + min_buffer;
      25              : }
      26              : 
      27              : std::shared_ptr<parser_config_impl const>
      28           28 : make_parser_config(parser_config cfg)
      29              : {
      30           28 :     if(cfg.max_prepare < 1)
      31            0 :         detail::throw_invalid_argument();
      32              : 
      33           28 :     auto impl = std::make_shared<parser_config_impl>(std::move(cfg));
      34              : 
      35              :     /*
      36              :         | fb |     cb0     |     cb1     | T | f |
      37              : 
      38              :         fb  flat_dynamic_buffer         headers.max_size
      39              :         cb0 circular_buffer     min_buffer
      40              :         cb1 circular_buffer     min_buffer
      41              :         T   body                max_type_erase
      42              :         f   table               max_table_space
      43              :     */
      44              : 
      45           28 :     std::size_t space_needed = 0;
      46              : 
      47           28 :     space_needed += impl->headers.valid_space_needed();
      48              : 
      49              :     // cb0_, cb1_
      50           28 :     space_needed += impl->min_buffer + impl->min_buffer;
      51              : 
      52              :     // T
      53           28 :     space_needed += impl->max_type_erase;
      54              : 
      55              :     // round up to alignof(detail::header::entry)
      56           28 :     auto const al = alignof(detail::header::entry);
      57           28 :     space_needed = al * ((space_needed + al - 1) / al);
      58              : 
      59           28 :     impl->space_needed = space_needed;
      60           28 :     impl->max_codec = 0;  // not currently used for parser
      61              : 
      62           56 :     return impl;
      63           28 : }
      64              : 
      65              : std::shared_ptr<serializer_config_impl const>
      66            1 : make_serializer_config(serializer_config cfg)
      67              : {
      68            1 :     auto impl = std::make_shared<serializer_config_impl>();
      69            1 :     static_cast<serializer_config&>(*impl) = std::move(cfg);
      70              : 
      71            1 :     std::size_t space_needed = 0;
      72            1 :     space_needed += impl->payload_buffer;
      73            1 :     space_needed += impl->max_type_erase;
      74              : 
      75            1 :     impl->space_needed = space_needed;
      76              : 
      77            2 :     return impl;
      78            1 : }
      79              : 
      80              : } // http
      81              : } // boost
        

Generated by: LCOV version 2.3