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

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
       3              : // Copyright (c) 2025 Mohammad Nejati
       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_REQUEST_PARSER_HPP
      12              : #define BOOST_HTTP_PROTO_REQUEST_PARSER_HPP
      13              : 
      14              : #include <boost/http_proto/detail/config.hpp>
      15              : #include <boost/http_proto/error.hpp>
      16              : #include <boost/http_proto/method.hpp>
      17              : #include <boost/http_proto/parser.hpp>
      18              : #include <boost/http_proto/request_view.hpp>
      19              : 
      20              : namespace boost {
      21              : namespace http_proto {
      22              : 
      23              : /// @copydoc parser
      24              : /// @brief A parser for HTTP/1 requests.
      25              : /// @see @ref response_parser.
      26              : class request_parser
      27              :     : public parser
      28              : {
      29              : public:
      30              :     /** Configuration settings for request_parser.
      31              : 
      32              :         @see
      33              :             @ref install_parser_service,
      34              :             @ref request_parser.
      35              :     */
      36              :     struct config : config_base
      37              :     {
      38              :         /** Constructor
      39              :         */
      40           23 :         config() noexcept
      41           23 :         {
      42           23 :             body_limit = 64 * 1024;
      43           23 :         }
      44              :     };
      45              : 
      46              :     /** Constructor.
      47              : 
      48              :         Constructs a parser that uses the @ref
      49              :         config parameters installed on the
      50              :         provided `ctx`.
      51              : 
      52              :         The parser will attempt to allocate
      53              :         the required space on startup, with the
      54              :         amount depending on the @ref config
      55              :         parameters, and will not perform any
      56              :         further allocations, except for Brotli
      57              :         decoder instances, if enabled.
      58              : 
      59              :         Depending on which compression algorithms
      60              :         are enabled in the @ref config, the parser
      61              :         will attempt to access the corresponding
      62              :         decoder services on the same `ctx`.
      63              : 
      64              :         @par Example
      65              :         @code
      66              :         request_parser sr(ctx);
      67              :         @endcode
      68              : 
      69              :         @par Complexity
      70              :         Constant.
      71              : 
      72              :         @par Exception Safety
      73              :         Calls to allocate may throw.
      74              : 
      75              :         @param ctx Context from which the
      76              :         request_parser will access registered
      77              :         services. The caller is responsible for
      78              :         ensuring that the provided ctx remains
      79              :         valid for the lifetime of the request_parser.
      80              : 
      81              :         @see
      82              :             @ref install_parser_service,
      83              :             @ref config.
      84              :     */
      85              :     BOOST_HTTP_PROTO_DECL
      86              :     explicit
      87              :     request_parser(const rts::context& ctx);
      88              : 
      89              :     /** Constructor.
      90              : 
      91              :         The states of `other` are transferred
      92              :         to the newly constructed object,
      93              :         including the allocated buffer.
      94              :         After construction, the only valid
      95              :         operations on the moved-from object
      96              :         are destruction and assignment.
      97              : 
      98              :         Buffer sequences previously obtained
      99              :         using @ref prepare or @ref pull_body
     100              :         remain valid.
     101              : 
     102              :         @par Complexity
     103              :         Constant.
     104              : 
     105              :         @param other The parser to move from.
     106              :     */
     107            2 :     request_parser(
     108              :         request_parser&& other) noexcept = default;
     109              : 
     110              :     /** Destructor.
     111              : 
     112              :         Any views or buffers obtained from this
     113              :         parser become invalid.
     114              :     */
     115         1026 :     ~request_parser() = default;
     116              : 
     117              :     /** Return a read-only view to the parsed request headers.
     118              : 
     119              :         The returned view remains valid until:
     120              :         @li @ref start is called
     121              :         @li @ref reset is called
     122              :         @li The parser instance is destroyed
     123              : 
     124              :         @par Preconditions
     125              :         @code
     126              :         this->got_header() == true
     127              :         @endcode
     128              : 
     129              :         @par Exception Safety
     130              :         Strong guarantee.
     131              : 
     132              :         @see
     133              :             @ref got_header.
     134              :     */
     135              :     BOOST_HTTP_PROTO_DECL
     136              :     request_view
     137              :     get() const;
     138              : };
     139              : 
     140              : } // http_proto
     141              : } // boost
     142              : 
     143              : #endif
        

Generated by: LCOV version 2.1