LCOV - code coverage report
Current view: top level - http_proto/impl - response.ipp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 10 60 16.7 %
Date: 2023-03-01 04:29:22 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             : #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           3 : response::
      22           3 : response() noexcept
      23             :     : fields_view_base(
      24           3 :         &this->fields_base::h_)
      25             :     , message_base(
      26           3 :         detail::kind::response)
      27             : {
      28           3 : }
      29             : 
      30          74 : response::
      31             : response(
      32          74 :     core::string_view s)
      33             :     : fields_view_base(
      34          74 :         &this->fields_base::h_)
      35             :     , message_base(
      36          74 :         detail::kind::response, s)
      37             : {
      38          74 : }
      39             : 
      40           0 : response::
      41             : response(
      42           0 :     response&& other) noexcept
      43           0 :     : response()
      44             : {
      45           0 :     swap(other);
      46           0 : }
      47             : 
      48           0 : response::
      49             : response(
      50           0 :     response const& other)
      51             :     : fields_view_base(
      52           0 :         &this->fields_base::h_)
      53           0 :     , message_base(*other.ph_)
      54             : {
      55           0 : }
      56             : 
      57           0 : response::
      58             : response(
      59           0 :     response_view const& other)
      60             :     : fields_view_base(
      61           0 :         &this->fields_base::h_)
      62           0 :     , message_base(*other.ph_)
      63             : {
      64           0 : }
      65             : 
      66             : response&
      67           0 : response::
      68             : operator=(
      69             :     response&& other) noexcept
      70             : {
      71             :     response temp(
      72           0 :         std::move(other));
      73           0 :     temp.swap(*this);
      74           0 :     return *this;
      75             : }
      76             : 
      77           0 : response::
      78             : response(
      79             :     http_proto::status sc,
      80           0 :     http_proto::version v)
      81           0 :     : response()
      82             : {
      83           0 :     if( sc != h_.res.status ||
      84           0 :         v != h_.version)
      85           0 :         set_start_line(sc, v);
      86           0 : }
      87             : 
      88             : //------------------------------------------------
      89             : 
      90             : void
      91           0 : response::
      92             : set_impl(
      93             :     http_proto::status sc,
      94             :     unsigned short si,
      95             :     core::string_view rs,
      96             :     http_proto::version v)
      97             : {
      98             :     // measure and resize
      99           0 :     auto const vs = to_string(v);
     100             :     auto const n =
     101           0 :         vs.size() + 1 +
     102           0 :         3 + 1 +
     103           0 :         rs.size() +
     104           0 :         2;
     105           0 :     auto dest = set_prefix_impl(n);
     106             : 
     107           0 :     h_.version = v;
     108           0 :     vs.copy(dest, vs.size());
     109           0 :     dest += vs.size();
     110           0 :     *dest++ = ' ';
     111             : 
     112           0 :     h_.res.status = sc;
     113           0 :     h_.res.status_int = si;
     114           0 :     dest[0] = '0' + ((h_.res.status_int / 100) % 10);
     115           0 :     dest[1] = '0' + ((h_.res.status_int /  10) % 10);
     116           0 :     dest[2] = '0' + ((h_.res.status_int /   1) % 10);
     117           0 :     dest[3] = ' ';
     118           0 :     dest += 4;
     119             : 
     120           0 :     rs.copy(dest, rs.size());
     121           0 :     dest += rs.size();
     122           0 :     dest[0] = '\r';
     123           0 :     dest[1] = '\n';
     124             : 
     125           0 :     h_.on_start_line();
     126           0 : }
     127             : 
     128             : } // http_proto
     129             : } // boost
     130             : 
     131             : #endif

Generated by: LCOV version 1.15