• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

llnl / dftracer-utils / 23531027933

25 Mar 2026 08:05AM UTC coverage: 48.592% (-1.5%) from 50.098%
23531027933

Pull #57

github

web-flow
Merge d1070e289 into 38f9f3616
Pull Request #57: feat(comparator): add pairwise traces comparator

18900 of 49456 branches covered (38.22%)

Branch coverage included in aggregate %.

1604 of 1954 new or added lines in 25 files covered. (82.09%)

3407 existing lines in 135 files now uncovered.

18487 of 27485 relevant lines covered (67.26%)

240991.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.01
/src/dftracer/utils/server/http_response.cpp
1
#include <dftracer/utils/server/http_response.h>
2

3
#include <algorithm>
4
#include <cctype>
5

6
namespace dftracer::utils::server {
7

8
namespace {
9

10
bool icase_equal(std::string_view a, std::string_view b) {
20✔
11
    if (a.size() != b.size()) return false;
20✔
12
    return std::equal(a.begin(), a.end(), b.begin(), [](char ca, char cb) {
15✔
13
        return std::tolower(static_cast<unsigned char>(ca)) ==
28✔
14
               std::tolower(static_cast<unsigned char>(cb));
14✔
15
    });
16
}
20✔
17

18
bool has_content_length(
20✔
19
    const std::vector<std::pair<std::string, std::string>> &headers) {
20
    return std::any_of(headers.begin(), headers.end(), [](const auto &h) {
40✔
21
        return icase_equal(h.first, "Content-Length");
20✔
22
    });
23
}
24

25
}  // namespace
26

27
std::string HttpResponse::serialize_headers() const {
22✔
28
    std::string out;
22✔
29
    out.reserve(256);
22!
30

31
    out += "HTTP/1.1 ";
22!
32
    out += std::to_string(status_code);
22!
33
    out += ' ';
22!
34
    out += status_text;
22!
35
    out += "\r\n";
22!
36

37
    for (const auto &[name, value] : headers) {
68✔
38
        out += name;
23!
39
        out += ": ";
23!
40
        out += value;
23!
41
        out += "\r\n";
23!
42
    }
43

44
    if (!body.empty() && !has_content_length(headers)) {
22!
45
        out += "Content-Length: ";
19!
46
        out += std::to_string(body.size());
19!
47
        out += "\r\n";
19!
48
    }
19✔
49

50
    out += "\r\n";
22!
51
    return out;
22✔
52
}
22!
53

54
std::string HttpResponse::serialize() const {
18✔
55
    auto out = serialize_headers();
18✔
56
    out += body;
18!
57
    return out;
18✔
58
}
18!
59

60
HttpResponse HttpResponse::ok() {
2✔
61
    return HttpResponse{
8✔
62
        .status_code = 200, .status_text = "OK", .headers = {}, .body = {}};
6✔
63
}
64

65
HttpResponse HttpResponse::ok(const std::string &body,
17✔
66
                              const std::string &content_type) {
67
    return HttpResponse{.status_code = 200,
51!
68
                        .status_text = "OK",
17✔
69
                        .headers = {{"Content-Type", content_type}},
17!
70
                        .body = body};
17!
UNCOV
71
}
×
72

73
HttpResponse HttpResponse::not_found() {
3✔
74
    return HttpResponse{.status_code = 404,
9!
75
                        .status_text = "Not Found",
3✔
76
                        .headers = {{"Content-Type", "text/plain"}},
3!
77
                        .body = "Not Found"};
3!
UNCOV
78
}
×
79

80
HttpResponse HttpResponse::bad_request(const std::string &msg) {
3✔
81
    return HttpResponse{.status_code = 400,
9!
82
                        .status_text = "Bad Request",
3✔
83
                        .headers = {{"Content-Type", "text/plain"}},
3!
84
                        .body = msg};
3!
UNCOV
85
}
×
86

87
HttpResponse HttpResponse::internal_error(const std::string &msg) {
1✔
88
    return HttpResponse{.status_code = 500,
3!
89
                        .status_text = "Internal Server Error",
1✔
90
                        .headers = {{"Content-Type", "text/plain"}},
1!
91
                        .body = msg};
1!
UNCOV
92
}
×
93

94
}  // namespace dftracer::utils::server
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc