GCC Code Coverage Report


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