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: 2024-07-03 18:58:30 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 BOOST_SYMBOL_VISIBLE
      27              :     message_view_base
      28              :     : public virtual fields_view_base
      29              : {
      30              :     friend class request_view;
      31              :     friend class response_view;
      32              :     friend class message_base;
      33              : 
      34          829 :     message_view_base() noexcept
      35              :         // VFALCO This ctor-init has to be
      36              :         // here even though it isn't called,
      37              :         // so nullptr doesn't matter.
      38          829 :         : fields_view_base(nullptr)
      39              :     {
      40          829 :     }
      41              : 
      42              :     explicit
      43              :     message_view_base(
      44              :         detail::header const* ph) noexcept
      45              :         : fields_view_base(ph)
      46              :     {
      47              :     }
      48              : 
      49              : public:
      50              :     //--------------------------------------------
      51              :     //
      52              :     // Metadata
      53              :     //
      54              :     //--------------------------------------------
      55              : 
      56              :     /** Return the type of payload of this message
      57              :     */
      58              :     auto
      59           38 :     payload() const noexcept ->
      60              :         http_proto::payload
      61              :     {
      62           38 :         return ph_->md.payload;
      63              :     }
      64              : 
      65              :     /** Return the payload size
      66              : 
      67              :         When @ref payload returns @ref payload::size,
      68              :         this function returns the number of octets
      69              :         in the actual message payload.
      70              :     */
      71              :     std::uint64_t
      72            2 :     payload_size() const noexcept
      73              :     {
      74            2 :         BOOST_ASSERT(
      75              :             payload() == payload::size);
      76            2 :         return ph_->md.payload_size;
      77              :     }
      78              : 
      79              :     /** Return true if semantics indicate connection persistence
      80              :     */
      81              :     bool
      82           22 :     keep_alive() const noexcept
      83              :     {
      84           22 :         return ph_->keep_alive();
      85              :     }
      86              : 
      87              :     /** Return metadata about the message
      88              :     */
      89              :     auto
      90          215 :     metadata() const noexcept ->
      91              :         http_proto::metadata const&
      92              :     {
      93          215 :         return ph_->md;
      94              :     }
      95              : 
      96              :     /** Return true if the message is using a chunked
      97              :         transfer encoding.
      98              :     */
      99              :     bool
     100         6324 :     chunked() const noexcept
     101              :     {
     102         6324 :         return ph_->md.transfer_encoding.is_chunked;
     103              :     }
     104              : };
     105              : 
     106              : } // http_proto
     107              : } // boost
     108              : 
     109              : #endif
        

Generated by: LCOV version 2.1