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 36x content_coding(fields_base const& headers) noexcept
26 {
27 using enum http::content_coding;
28 using urls::grammar::ci_is_equal;
29
30 36x auto const it = headers.find(http::field::content_encoding);
31
2/2
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 13 times.
36x if(it == headers.end())
32 23x return identity;
33
34
2/2
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
26x if(auto rv = urls::grammar::parse(
35 26x it->value, http::token_rule))
36 {
37
2/2
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 10 times.
11x if(ci_is_equal(*rv, "identity"))
38 10x return identity;
39
2/2
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 9 times.
10x if(ci_is_equal(*rv, "deflate"))
40 1x return deflate;
41
2/2
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 5 times.
9x if(ci_is_equal(*rv, "gzip"))
42 4x return gzip;
43
2/2
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 3 times.
5x if(ci_is_equal(*rv, "br"))
44 2x return br;
45
2/2
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1 time.
3x if(ci_is_equal(*rv, "zstd"))
46 2x return zstd;
47 }
48
49 3x return unknown;
50 }
51
52 } // namespace detail
53 } // namespace burl
54 } // namespace boost
55