LCOV - code coverage report
Current view: top level - src - header_limits.cpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 5 5
Test Date: 2026-06-13 19:44:58 Functions: 100.0 % 1 1

           TLA  Line data    Source code
       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
       8                 : //
       9                 : 
      10                 : #include <boost/http/header_limits.hpp>
      11                 : #include <boost/http/detail/except.hpp>
      12                 : #include <boost/http/detail/header.hpp>
      13                 : 
      14                 : namespace boost {
      15                 : namespace http {
      16                 : 
      17                 : std::size_t
      18 HIT         115 : 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_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             115 :     return Align * (
      68             115 :         (max_size + Align - 1) / Align) + (
      69             115 :             max_fields * sizeof(
      70             115 :                 detail::header::entry));
      71                 : }
      72                 : 
      73                 : } // http
      74                 : } // boost
        

Generated by: LCOV version 2.3