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 % 16 16
Test Date: 2025-09-21 18:08:14 Functions: 100.0 % 7 7

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

Generated by: LCOV version 2.1