src/detail/content_coding.cpp

100.0% Lines (17/17) 100.0% List of functions (1/1) 100.0% Branches (14/14)
content_coding.cpp
f(x) Functions (1)
Line Branch TLA Hits Source Code
1 //
2 // Copyright (c) 2026 Mohammad Nejati
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/burl
8 //
9
10 #include "content_coding.hpp"
11
12 #include <boost/core/detail/string_view.hpp>
13 #include <boost/http/rfc/token_rule.hpp>
14 #include <boost/url/grammar/ci_string.hpp>
15 #include <boost/url/grammar/parse.hpp>
16
17 namespace boost
18 {
19 namespace burl
20 {
21 namespace detail
22 {
23
24 http::content_coding
25 282x content_coding(fields_base const& headers) noexcept
26 {
27 using enum http::content_coding;
28 using urls::grammar::ci_is_equal;
29
30 282x auto const it = headers.find(http::field::content_encoding);
31
2/2
✓ Branch 2 taken 261 times.
✓ Branch 3 taken 21 times.
282x if(it == headers.end())
32 261x return identity;
33
34
2/2
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 2 times.
42x if(auto rv = urls::grammar::parse(
35 42x it->value, http::token_rule))
36 {
37
2/2
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 18 times.
19x if(ci_is_equal(*rv, "identity"))
38 18x return identity;
39
2/2
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 17 times.
18x if(ci_is_equal(*rv, "deflate"))
40 1x return deflate;
41
2/2
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 6 times.
17x if(ci_is_equal(*rv, "gzip"))
42 11x return gzip;
43
2/2
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 4 times.
6x if(ci_is_equal(*rv, "br"))
44 2x return br;
45
2/2
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 1 time.
4x if(ci_is_equal(*rv, "zstd"))
46 3x return zstd;
47 }
48
49 3x return unknown;
50 }
51
52 } // namespace detail
53 } // namespace burl
54 } // namespace boost
55