LCOV - code coverage report
Current view: top level - http_proto - response_parser.hpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 15 15 100.0 %
Date: 2023-02-11 03:18:39 Functions: 6 6 100.0 %

          Line data    Source code
       1             : //
       2             : // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
       3             : //
       4             : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       5             : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       6             : //
       7             : // Official repository: https://github.com/CPPAlliance/http_proto
       8             : //
       9             : 
      10             : #ifndef BOOST_HTTP_PROTO_RESPONSE_PARSER_HPP
      11             : #define BOOST_HTTP_PROTO_RESPONSE_PARSER_HPP
      12             : 
      13             : #include <boost/http_proto/detail/config.hpp>
      14             : #include <boost/http_proto/error.hpp>
      15             : #include <boost/http_proto/parser.hpp>
      16             : #include <boost/http_proto/response_view.hpp>
      17             : #include <boost/http_proto/status.hpp>
      18             : #include <cstddef>
      19             : 
      20             : namespace boost {
      21             : namespace http_proto {
      22             : 
      23             : class BOOST_SYMBOL_VISIBLE
      24             :     response_parser
      25             :     : public parser
      26             : {
      27             : public:
      28             :     /** Configuration settings for parsing requests
      29             :     */
      30             :     struct config : config_base
      31             :     {
      32             :         /** Constructor
      33             :         */
      34           7 :         config() noexcept
      35           7 :         {
      36           7 :             body_limit = 1024 * 1024;
      37           7 :         }
      38             :     };
      39             : 
      40             :     /** Constructor
      41             :     */
      42             :     BOOST_HTTP_PROTO_DECL
      43             :     response_parser();
      44             : 
      45             :     /** Constructor
      46             :     */
      47             :     template<class... Params>
      48             :     explicit
      49           6 :     response_parser(
      50             :         std::size_t extra_buffer_size,
      51             :         Params&&... params)
      52             :         : parser(
      53             :             detail::kind::response,
      54           6 :             config{})
      55             :     {
      56           6 :         this->apply_params(
      57             :             std::forward<Params>(params)...);
      58           6 :         construct(extra_buffer_size);
      59           6 :     }
      60             : 
      61             :     /** Prepare for the next message on the stream.
      62             :     */
      63             :     void
      64           1 :     start()
      65             :     {
      66           1 :         start_impl(false);
      67           1 :     }
      68             : 
      69             :     /** Prepare for the next message on the stream.
      70             : 
      71             :         This informs the parser not to read a
      72             :         payload for the next message, regardless
      73             :         of the presence or absence of certain
      74             :         fields such as Content-Length or a chunked
      75             :         Transfer-Encoding. Depending on the request,
      76             :         some responses do not carry a body. For
      77             :         example, a 200 response to a CONNECT
      78             :         request from a tunneling proxy, or a
      79             :         response to a HEAD request. In these
      80             :         cases, callers may use this function
      81             :         inform the parser that no body is
      82             :         expected. The parser will consider the
      83             :         message complete after the header has
      84             :         been received.
      85             : 
      86             :         @par Preconditions
      87             : 
      88             :         This function must called before any calls to parse
      89             :         the current message.
      90             : 
      91             :         @see
      92             :             https://datatracker.ietf.org/doc/html/rfc7230#section-3.3
      93             :     */
      94             :     void
      95           1 :     start_head_response()
      96             :     {
      97           1 :         start_impl(true);
      98           1 :     }
      99             : 
     100             :     /** Return the parsed response headers.
     101             :     */
     102             :     BOOST_HTTP_PROTO_DECL
     103             :     response_view
     104             :     get() const;
     105             : };
     106             : 
     107             : } // http_proto
     108             : } // boost
     109             : 
     110             : #endif

Generated by: LCOV version 1.15