LCOV - code coverage report
Current view: top level - boost/http_proto/response_parser.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 4 4
Test Date: 2025-06-15 05:10:37 Functions: 100.0 % 1 1

            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 response_parser
      24              :     : public parser
      25              : {
      26              : public:
      27              :     /** Configuration settings for parsing requests
      28              :     */
      29              :     struct config : config_base
      30              :     {
      31              :         /** Constructor
      32              :         */
      33           15 :         config() noexcept
      34           15 :         {
      35           15 :             body_limit = 1024 * 1024;
      36           15 :         }
      37              :     };
      38              : 
      39              :     /** Constructor
      40              :     */
      41              :     BOOST_HTTP_PROTO_DECL
      42              :     explicit
      43              :     response_parser(context& ctx);
      44              : 
      45              :     /** Prepare for the next message on the stream.
      46              : 
      47              :         This informs the parser not to read a
      48              :         payload for the next message, regardless
      49              :         of the presence or absence of certain
      50              :         fields such as Content-Length or a chunked
      51              :         Transfer-Encoding. Depending on the request,
      52              :         some responses do not carry a body. For
      53              :         example, a 200 response to a CONNECT
      54              :         request from a tunneling proxy, or a
      55              :         response to a HEAD request. In these
      56              :         cases, callers may use this function
      57              :         inform the parser that no body is
      58              :         expected. The parser will consider the
      59              :         message complete after the header has
      60              :         been received.
      61              : 
      62              :         @par Preconditions
      63              : 
      64              :         This function must called before any calls to parse
      65              :         the current message.
      66              : 
      67              :         @see
      68              :             https://datatracker.ietf.org/doc/html/rfc7230#section-3.3
      69              :     */
      70              :     void
      71              :     start_head_response()
      72              :     {
      73              :         start_impl(true);
      74              :     }
      75              : 
      76              :     /** Return a read-only view to the parsed response headers.
      77              : 
      78              :         The returned view becomes invalid after calling 
      79              :         @ref start or @ref reset.
      80              : 
      81              :         @par Preconditions
      82              :         This function can be called only after the
      83              :         header is fully parsed.
      84              : 
      85              :         @return A read-only view to the parsed response headers.
      86              :     */
      87              :     BOOST_HTTP_PROTO_DECL
      88              :     response_view
      89              :     get() const;
      90              : };
      91              : 
      92              : } // http_proto
      93              : } // boost
      94              : 
      95              : #endif
        

Generated by: LCOV version 2.1