GCC Code Coverage Report


Directory: ./
File: libs/http_proto/src/server/route_handler.cpp
Date: 2025-12-04 09:48:34
Exec Total Coverage
Lines: 3 19 15.8%
Functions: 1 4 25.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&
24 route_params::
25 status(
26 http_proto::status code)
27 {
28 res.set_start_line(code, res.version());
29 return *this;
30 }
31
32 route_params&
33 route_params::
34 set_body(std::string s)
35 {
36 if(! res.exists(http_proto::field::content_type))
37 {
38 // VFALCO TODO detect Content-Type
39 res.set(http_proto::field::content_type,
40 "text/plain; charset=UTF-8");
41 }
42
43 if(! res.exists(field::content_length))
44 {
45 res.set_payload_size(s.size());
46 }
47
48 serializer.start(res,
49 http_proto::string_body(std::string(s)));
50
51 return *this;
52 }
53
54 void
55 route_params::
56 do_post()
57 {
58 BOOST_ASSERT(task_);
59 // invoke until task resumes
60 for(;;)
61 if(task_->invoke())
62 break;
63 }
64
65 } // http_proto
66 } // boost
67