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 % 10 10
Test Date: 2025-12-05 19:49:25 Functions: 100.0 % 5 5

            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/static_request.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 BOOST_HTTP_PROTO_DECL 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           24 :         config() noexcept
      41           24 :         {
      42           24 :             body_limit = 64 * 1024;
      43           24 :         }
      44              :     };
      45              : 
      46              :     /** Destructor.
      47              : 
      48              :         Any views or buffers obtained from this
      49              :         parser become invalid.
      50              :     */
      51         1033 :     ~request_parser() = default;
      52              : 
      53              :     /** Constructor.
      54              : 
      55              :         Default-constructed parsers do not reference any
      56              :         implementation and therefore must be assigned to before using.
      57              :     */
      58            6 :     request_parser() noexcept = default;
      59              : 
      60              :     /** Constructor.
      61              : 
      62              :         The states of `other` are transferred
      63              :         to the newly constructed object,
      64              :         including the allocated buffer.
      65              :         After construction, the only valid
      66              :         operations on the moved-from object
      67              :         are destruction and assignment.
      68              : 
      69              :         Buffer sequences previously obtained
      70              :         using @ref prepare or @ref pull_body
      71              :         remain valid.
      72              : 
      73              :         @par Complexity
      74              :         Constant.
      75              : 
      76              :         @param other The parser to move from.
      77              :     */
      78            2 :     request_parser(
      79              :         request_parser&& other) noexcept = default;
      80              : 
      81              :     /** Assignment.
      82              :         The states of `other` are transferred
      83              :         to this object, including the allocated
      84              :         buffer.
      85              :         After assignment, the only valid
      86              :         operations on the moved-from object
      87              :         are destruction and assignment.
      88              :         Buffer sequences previously obtained
      89              :         using @ref prepare or @ref pull_body
      90              :         remain valid.
      91              :         @par Complexity
      92              :         Constant.
      93              :         @param other The parser to move from.
      94              :     */
      95              :     request_parser&
      96            2 :     operator=(request_parser&& other) noexcept
      97              :     {
      98            2 :         assign(std::move(other));
      99            2 :         return *this;
     100              :     }
     101              : 
     102              :     /** Constructor.
     103              : 
     104              :         Constructs a parser that uses the @ref
     105              :         config parameters installed on the
     106              :         provided `ctx`.
     107              : 
     108              :         The parser will attempt to allocate
     109              :         the required space on startup, with the
     110              :         amount depending on the @ref config
     111              :         parameters, and will not perform any
     112              :         further allocations, except for Brotli
     113              :         decoder instances, if enabled.
     114              : 
     115              :         Depending on which compression algorithms
     116              :         are enabled in the @ref config, the parser
     117              :         will attempt to access the corresponding
     118              :         decoder services on the same `ctx`.
     119              : 
     120              :         @par Example
     121              :         @code
     122              :         request_parser sr(ctx);
     123              :         @endcode
     124              : 
     125              :         @par Complexity
     126              :         Constant.
     127              : 
     128              :         @par Exception Safety
     129              :         Calls to allocate may throw.
     130              : 
     131              :         @param ctx Context from which the
     132              :         request_parser will access registered
     133              :         services. The caller is responsible for
     134              :         ensuring that the provided ctx remains
     135              :         valid for the lifetime of the request_parser.
     136              : 
     137              :         @see
     138              :             @ref install_parser_service,
     139              :             @ref config.
     140              :     */
     141              :     explicit
     142              :     request_parser(capy::polystore& ctx);
     143              : 
     144              :     /** Return a reference to the parsed request headers.
     145              : 
     146              :         The returned reference remains valid until:
     147              :         @li @ref start is called
     148              :         @li @ref reset is called
     149              :         @li The parser instance is destroyed
     150              : 
     151              :         @par Preconditions
     152              :         @code
     153              :         this->got_header() == true
     154              :         @endcode
     155              : 
     156              :         @par Exception Safety
     157              :         Strong guarantee.
     158              : 
     159              :         @see
     160              :             @ref got_header.
     161              :     */
     162              :     static_request const&
     163              :     get() const;
     164              : };
     165              : 
     166              : } // http_proto
     167              : } // boost
     168              : 
     169              : #endif
        

Generated by: LCOV version 2.1