LCOV - code coverage report
Current view: top level - libs/http_proto/src/server - route_handler.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 27.3 % 22 6
Test Date: 2025-12-02 19:05:12 Functions: 33.3 % 6 2

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2025 Vinnie Falco (vinnie dot falco at gmail dot 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              : #include <boost/http_proto/server/route_handler.hpp>
      11              : #include <boost/http_proto/string_body.hpp>
      12              : #include <boost/assert.hpp>
      13              : #include <cstring>
      14              : 
      15              : namespace boost {
      16              : namespace http_proto {
      17              : 
      18            1 : Response::
      19            1 : Response()
      20              : {
      21            1 : }
      22              : 
      23            1 : Response::
      24            1 : ~Response()
      25              : {
      26            1 : }
      27              : 
      28              : Response&
      29            0 : Response::
      30              : status(
      31              :     http_proto::status code)
      32              : {
      33            0 :     message.set_start_line(code, message.version());
      34            0 :     return *this;
      35              : }
      36              : 
      37              : Response&
      38            0 : Response::
      39              : set_body(std::string s)
      40              : {
      41            0 :     if(! message.exists(http_proto::field::content_type))
      42              :     {
      43              :         // VFALCO TODO detect Content-Type
      44            0 :         message.set(http_proto::field::content_type,
      45              :             "text/plain; charset=UTF-8");
      46              :     }
      47              : 
      48            0 :     if(!message.exists(http_proto::field::content_length))
      49              :     {
      50            0 :         message.set_payload_size(s.size());
      51              :     }
      52              : 
      53            0 :     serializer.start(message,
      54            0 :         http_proto::string_body(std::string(s)));
      55              : 
      56            0 :     return *this;
      57              : }
      58              : 
      59              : void
      60            0 : Response::
      61              : do_post()
      62              : {
      63            0 :     BOOST_ASSERT(task_);
      64              :     // invoke until task resumes
      65              :     for(;;)
      66            0 :         if(task_->invoke())
      67            0 :             break;
      68            0 : }
      69              : 
      70              : } // http_proto
      71              : } // boost
        

Generated by: LCOV version 2.1