GCC Code Coverage Report


Directory: ./
File: libs/http_proto/src/server/route_handler.cpp
Date: 2025-12-05 19:49:26
Exec Total Coverage
Lines: 3 20 15.0%
Functions: 1 5 20.0%
Branches: 0 11 0.0%

Line Branch Exec Source
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 route_params::
19 1 ~route_params()
20 {
21 1 }
22
23 route_params::task::
24 ~task() = default;
25
26 route_params&
27 route_params::
28 status(
29 http_proto::status code)
30 {
31 res.set_start_line(code, res.version());
32 return *this;
33 }
34
35 route_params&
36 route_params::
37 set_body(std::string s)
38 {
39 if(! res.exists(http_proto::field::content_type))
40 {
41 // VFALCO TODO detect Content-Type
42 res.set(http_proto::field::content_type,
43 "text/plain; charset=UTF-8");
44 }
45
46 if(! res.exists(field::content_length))
47 {
48 res.set_payload_size(s.size());
49 }
50
51 serializer.start(res,
52 http_proto::string_body(std::string(s)));
53
54 return *this;
55 }
56
57 void
58 route_params::
59 do_post()
60 {
61 BOOST_ASSERT(task_);
62 // invoke until task resumes
63 for(;;)
64 if(task_->invoke())
65 break;
66 }
67
68 } // http_proto
69 } // boost
70