LCOV - code coverage report
Current view: top level - libs/http_proto/src - response.cpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 10 60 16.7 %
Date: 2024-01-17 18:52:26 Functions: 2 14 14.3 %

          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_proto
       8             : //
       9             : 
      10             : #include <boost/http_proto/response.hpp>
      11             : #include <boost/http_proto/response_view.hpp>
      12             : #include "detail/copied_strings.hpp"
      13             : #include <utility>
      14             : 
      15             : namespace boost {
      16             : namespace http_proto {
      17             : 
      18           3 : response::
      19           3 : response() noexcept
      20             :     : fields_view_base(
      21           3 :         &this->fields_base::h_)
      22             :     , message_base(
      23           3 :         detail::kind::response)
      24             : {
      25           3 : }
      26             : 
      27          75 : response::
      28             : response(
      29          75 :     core::string_view s)
      30             :     : fields_view_base(
      31          75 :         &this->fields_base::h_)
      32             :     , message_base(
      33          75 :         detail::kind::response, s)
      34             : {
      35          75 : }
      36             : 
      37           0 : response::
      38             : response(
      39           0 :     response&& other) noexcept
      40           0 :     : response()
      41             : {
      42           0 :     swap(other);
      43           0 : }
      44             : 
      45           0 : response::
      46             : response(
      47           0 :     response const& other)
      48             :     : fields_view_base(
      49           0 :         &this->fields_base::h_)
      50           0 :     , message_base(*other.ph_)
      51             : {
      52           0 : }
      53             : 
      54           0 : response::
      55             : response(
      56           0 :     response_view const& other)
      57             :     : fields_view_base(
      58           0 :         &this->fields_base::h_)
      59           0 :     , message_base(*other.ph_)
      60             : {
      61           0 : }
      62             : 
      63             : response&
      64           0 : response::
      65             : operator=(
      66             :     response&& other) noexcept
      67             : {
      68             :     response temp(
      69           0 :         std::move(other));
      70           0 :     temp.swap(*this);
      71           0 :     return *this;
      72             : }
      73             : 
      74           0 : response::
      75             : response(
      76             :     http_proto::status sc,
      77           0 :     http_proto::version v)
      78           0 :     : response()
      79             : {
      80           0 :     if( sc != h_.res.status ||
      81           0 :         v != h_.version)
      82           0 :         set_start_line(sc, v);
      83           0 : }
      84             : 
      85             : //------------------------------------------------
      86             : 
      87             : void
      88           0 : response::
      89             : set_impl(
      90             :     http_proto::status sc,
      91             :     unsigned short si,
      92             :     core::string_view rs,
      93             :     http_proto::version v)
      94             : {
      95             :     // measure and resize
      96           0 :     auto const vs = to_string(v);
      97             :     auto const n =
      98           0 :         vs.size() + 1 +
      99           0 :         3 + 1 +
     100           0 :         rs.size() +
     101           0 :         2;
     102           0 :     auto dest = set_prefix_impl(n);
     103             : 
     104           0 :     h_.version = v;
     105           0 :     vs.copy(dest, vs.size());
     106           0 :     dest += vs.size();
     107           0 :     *dest++ = ' ';
     108             : 
     109           0 :     h_.res.status = sc;
     110           0 :     h_.res.status_int = si;
     111           0 :     dest[0] = '0' + ((h_.res.status_int / 100) % 10);
     112           0 :     dest[1] = '0' + ((h_.res.status_int /  10) % 10);
     113           0 :     dest[2] = '0' + ((h_.res.status_int /   1) % 10);
     114           0 :     dest[3] = ' ';
     115           0 :     dest += 4;
     116             : 
     117           0 :     rs.copy(dest, rs.size());
     118           0 :     dest += rs.size();
     119           0 :     dest[0] = '\r';
     120           0 :     dest[1] = '\n';
     121             : 
     122           0 :     h_.on_start_line();
     123           0 : }
     124             : 
     125             : } // http_proto
     126             : } // boost

Generated by: LCOV version 1.15