LCOV - code coverage report
Current view: top level - http_proto/impl - response.ipp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 29 55 52.7 %
Date: 2023-01-15 07:18:31 Functions: 2 12 16.7 %

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

Generated by: LCOV version 1.15