LCOV - code coverage report
Current view: top level - libs/http_proto/src/server - helmet.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 0.0 % 23 0
Test Date: 2025-12-21 20:19:40 Functions: 0.0 % 3 0

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2025 Amlal El Mahrouss (amlal at nekernel dot org)
       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/server/helmet.hpp>
      11              : 
      12              : namespace boost {
      13              : namespace http_proto {
      14              : 
      15              : namespace detail {
      16            0 :     auto setHeaderValues(const std::vector<std::string>& fields_value) -> std::string {
      17            0 :         if (fields_value.empty())
      18            0 :             detail::throw_invalid_argument();
      19              : 
      20            0 :         std::string res_value;
      21            0 :         bool first = false;
      22              : 
      23            0 :         for (const auto& value: fields_value)
      24              :         {
      25            0 :             if (first) res_value += "; ";
      26            0 :             res_value += value;
      27            0 :             first = true;
      28              :         }
      29              : 
      30            0 :         return res_value;
      31            0 :     }
      32              : }
      33              : 
      34            0 : helmet::
      35              : helmet(
      36            0 :     helmet_options options) noexcept
      37            0 :     : options_(std::move(options))
      38              : {
      39            0 :     for (auto& hdr : options_.requestHeaders.headers)
      40              :     {
      41            0 :         if (hdr.second.empty())
      42            0 :             detail::throw_length_error();
      43              : 
      44            0 :         options_.requestHeaders.cachedHeaders.push_back(std::make_pair(hdr.first, detail::setHeaderValues(hdr.second)));
      45              :     }
      46            0 : }
      47              : 
      48              : route_result
      49            0 : helmet::
      50              : operator()(
      51              :     route_params& p) const
      52              : {
      53            0 :     for (const auto& hdr : options_.requestHeaders.cachedHeaders)
      54              :     {
      55            0 :         p.res.set(hdr.first, hdr.second);
      56              :     }
      57              : 
      58            0 :     return route::next;
      59              : }
      60              : 
      61              : }
      62              : }
        

Generated by: LCOV version 2.1