LCOV - code coverage report
Current view: top level - boost/http_proto/message_view_base.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 14 14
Test Date: 2025-06-18 09:40:26 Functions: 100.0 % 6 6

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com)
       3              : // Copyright (c) 2024 Christian Mazakas
       4              : //
       5              : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       6              : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       7              : //
       8              : // Official repository: https://github.com/cppalliance/http_proto
       9              : //
      10              : 
      11              : #ifndef BOOST_HTTP_PROTO_MESSAGE_VIEW_BASE_HPP
      12              : #define BOOST_HTTP_PROTO_MESSAGE_VIEW_BASE_HPP
      13              : 
      14              : #include <boost/http_proto/detail/config.hpp>
      15              : #include <boost/http_proto/fields_view_base.hpp>
      16              : #include <boost/url/grammar/recycled.hpp>
      17              : #include <boost/url/grammar/type_traits.hpp>
      18              : #include <memory>
      19              : #include <string>
      20              : 
      21              : namespace boost {
      22              : namespace http_proto {
      23              : 
      24              : /** Provides message metadata for requests and responses
      25              : */
      26              : class message_view_base
      27              :     : public virtual fields_view_base
      28              : {
      29              :     friend class request_view;
      30              :     friend class response_view;
      31              :     friend class message_base;
      32              : 
      33          968 :     message_view_base() noexcept
      34              :         // VFALCO This ctor-init has to be
      35              :         // here even though it isn't called,
      36              :         // so nullptr doesn't matter.
      37          968 :         : fields_view_base(nullptr)
      38              :     {
      39          968 :     }
      40              : 
      41              :     explicit
      42              :     message_view_base(
      43              :         detail::header const* ph) noexcept
      44              :         : fields_view_base(ph)
      45              :     {
      46              :     }
      47              : 
      48              : public:
      49              :     //--------------------------------------------
      50              :     //
      51              :     // Metadata
      52              :     //
      53              :     //--------------------------------------------
      54              : 
      55              :     /** Return the type of payload of this message
      56              :     */
      57              :     auto
      58           39 :     payload() const noexcept ->
      59              :         http_proto::payload
      60              :     {
      61           39 :         return ph_->md.payload;
      62              :     }
      63              : 
      64              :     /** Return the payload size
      65              : 
      66              :         When @ref payload returns @ref payload::size,
      67              :         this function returns the number of octets
      68              :         in the actual message payload.
      69              :     */
      70              :     std::uint64_t
      71            2 :     payload_size() const noexcept
      72              :     {
      73            2 :         BOOST_ASSERT(
      74              :             payload() == payload::size);
      75            2 :         return ph_->md.payload_size;
      76              :     }
      77              : 
      78              :     /** Return true if semantics indicate connection persistence
      79              :     */
      80              :     bool
      81           22 :     keep_alive() const noexcept
      82              :     {
      83           22 :         return ph_->keep_alive();
      84              :     }
      85              : 
      86              :     /** Return metadata about the message
      87              :     */
      88              :     auto
      89          267 :     metadata() const noexcept ->
      90              :         http_proto::metadata const&
      91              :     {
      92          267 :         return ph_->md;
      93              :     }
      94              : 
      95              :     /** Return true if the message is using a chunked
      96              :         transfer encoding.
      97              :     */
      98              :     bool
      99         4568 :     chunked() const noexcept
     100              :     {
     101         4568 :         return ph_->md.transfer_encoding.is_chunked;
     102              :     }
     103              : };
     104              : 
     105              : } // http_proto
     106              : } // boost
     107              : 
     108              : #endif
        

Generated by: LCOV version 2.1