GCC Code Coverage Report


Directory: ./
File: libs/beast2/src/server/route_handler.cpp
Date: 2025-11-20 15:35:53
Exec Total Coverage
Lines: 0 15 0.0%
Functions: 0 3 0.0%
Branches: 0 9 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/beast2
8 //
9
10 #include <boost/beast2/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 beast2 {
17
18 route_result
19 Response::
20 fail(system::error_code const& ec)
21 {
22 if(! ec.failed())
23 detail::throw_invalid_argument();
24 return ec;
25 }
26
27 Response&
28 Response::
29 status(
30 http_proto::status code)
31 {
32 message.set_start_line(code, message.version());
33 return *this;
34 }
35
36 Response&
37 Response::
38 set_body(std::string s)
39 {
40 if(! message.exists(http_proto::field::content_type))
41 {
42 // VFALCO TODO detect Content-Type
43 message.set(http_proto::field::content_type,
44 "text/plain; charset=UTF-8");
45 }
46
47 if(!message.exists(http_proto::field::content_length))
48 {
49 message.set_payload_size(s.size());
50 }
51
52 serializer.start(message,
53 http_proto::string_body(std::string(s)));
54
55 return *this;
56 }
57
58 } // beast2
59 } // boost
60