LCOV - code coverage report
Current view: top level - libs/http_proto/src/response_base.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 25 25
Test Date: 2025-06-15 05:10:37 Functions: 100.0 % 1 1

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2025 Mohammad Nejati
       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/response_base.hpp>
      11              : 
      12              : #include <cstring>
      13              : 
      14              : namespace boost {
      15              : namespace http_proto {
      16              : 
      17              : void
      18           36 : response_base::
      19              : set_impl(
      20              :     http_proto::status sc,
      21              :     unsigned short si,
      22              :     core::string_view rs,
      23              :     http_proto::version v)
      24              : {
      25           36 :     auto const vs = to_string(v);
      26              :     auto const new_prefix =
      27           36 :         vs.size() + 1 + // HTTP-version SP
      28           36 :         3 + 1 +         // status-code SP
      29           36 :         rs.size() + 2;  // reason-phrase CRLF
      30              : 
      31              :     // Introduce a new scope so that prefix_op's
      32              :     // destructor runs before h_.on_start_line().
      33              :     {
      34           36 :         auto op = prefix_op_t(*this, new_prefix, &rs);
      35           36 :         char* dest = h_.buf;
      36              : 
      37           36 :         h_.version = v;
      38           36 :         vs.copy(dest, vs.size());
      39           36 :         dest += vs.size();
      40           36 :         *dest++ = ' ';
      41              : 
      42           36 :         h_.res.status = sc;
      43           36 :         h_.res.status_int = si;
      44           36 :         dest[0] = '0' + ((h_.res.status_int / 100) % 10);
      45           36 :         dest[1] = '0' + ((h_.res.status_int /  10) % 10);
      46           36 :         dest[2] = '0' + ((h_.res.status_int /   1) % 10);
      47           36 :         dest[3] = ' ';
      48           36 :         dest += 4;
      49              : 
      50           36 :         std::memmove(dest, rs.data(), rs.size());
      51           36 :         dest += rs.size();
      52           36 :         dest[0] = '\r';
      53           36 :         dest[1] = '\n';
      54           36 :     }
      55              : 
      56           36 :     h_.on_start_line();
      57           36 : }
      58              : 
      59              : } // http_proto
      60              : } // boost
        

Generated by: LCOV version 2.1