src/request_builder.cpp
100.0% Lines (26/26)
100.0% List of functions (6/6)
100.0% Branches (13/13)
Functions (6)
Function
Calls
Lines
Branches
Blocks
boost::burl::request_builder::query(std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> >) &&
:23
6x
100.0%
100.0%
70.0%
boost::burl::request_builder::header(boost::http::field, std::basic_string_view<char, std::char_traits<char> >) &&
:30
6x
100.0%
100.0%
100.0%
boost::burl::request_builder::header(std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> >) &&
:37
4x
100.0%
100.0%
86.0%
boost::burl::request_builder::basic_auth(std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> >) &&
:44
1x
100.0%
100.0%
65.0%
boost::burl::request_builder::bearer_auth(std::basic_string_view<char, std::char_traits<char> >) &&
:58
2x
100.0%
100.0%
67.0%
boost::burl::request_builder::send() &&
:68
33x
100.0%
100.0%
78.0%
| 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 <boost/burl/client.hpp> | |||
| 11 | ||||
| 12 | #include "detail/base64.hpp" | |||
| 13 | ||||
| 14 | #include <string> | |||
| 15 | #include <string_view> | |||
| 16 | ||||
| 17 | namespace boost | |||
| 18 | { | |||
| 19 | namespace burl | |||
| 20 | { | |||
| 21 | ||||
| 22 | request_builder&& | |||
| 23 | 6x | request_builder::query(std::string_view key, std::string_view value) && | ||
| 24 | { | |||
| 25 |
1/1✓ Branch 4 taken 6 times.
|
6x | request_.url.params().append({ key, value }); | |
| 26 | 6x | return std::move(*this); | ||
| 27 | } | |||
| 28 | ||||
| 29 | request_builder&& | |||
| 30 | 6x | request_builder::header(http::field field, std::string_view value) && | ||
| 31 | { | |||
| 32 |
1/1✓ Branch 2 taken 6 times.
|
6x | request_.headers.set(field, value); | |
| 33 | 6x | return std::move(*this); | ||
| 34 | } | |||
| 35 | ||||
| 36 | request_builder&& | |||
| 37 | 4x | request_builder::header(std::string_view name, std::string_view value) && | ||
| 38 | { | |||
| 39 |
1/1✓ Branch 3 taken 4 times.
|
4x | request_.headers.set(name, value); | |
| 40 | 4x | return std::move(*this); | ||
| 41 | } | |||
| 42 | ||||
| 43 | request_builder&& | |||
| 44 | 1x | request_builder::basic_auth(std::string_view user, std::string_view pass) && | ||
| 45 | { | |||
| 46 |
1/1✓ Branch 1 taken 1 time.
|
1x | std::string credentials{ user }; | |
| 47 |
1/1✓ Branch 1 taken 1 time.
|
1x | credentials += ':'; | |
| 48 |
1/1✓ Branch 1 taken 1 time.
|
1x | credentials += pass; | |
| 49 | ||||
| 50 |
1/1✓ Branch 1 taken 1 time.
|
1x | std::string value = "Basic "; | |
| 51 |
1/1✓ Branch 2 taken 1 time.
|
1x | detail::base64_encode(value, credentials); | |
| 52 | ||||
| 53 |
1/1✓ Branch 2 taken 1 time.
|
1x | request_.headers.set(http::field::authorization, value); | |
| 54 | 2x | return std::move(*this); | ||
| 55 | 1x | } | ||
| 56 | ||||
| 57 | request_builder&& | |||
| 58 | 2x | request_builder::bearer_auth(std::string_view token) && | ||
| 59 | { | |||
| 60 |
1/1✓ Branch 1 taken 2 times.
|
2x | std::string value = "Bearer "; | |
| 61 |
1/1✓ Branch 1 taken 2 times.
|
2x | value += token; | |
| 62 | ||||
| 63 |
1/1✓ Branch 2 taken 2 times.
|
2x | request_.headers.set(http::field::authorization, value); | |
| 64 | 4x | return std::move(*this); | ||
| 65 | 2x | } | ||
| 66 | ||||
| 67 | capy::io_task<response> | |||
| 68 | 33x | request_builder::send() && | ||
| 69 | { | |||
| 70 |
1/1✓ Branch 3 taken 33 times.
|
33x | return client_.execute(std::move(request_)); | |
| 71 | } | |||
| 72 | ||||
| 73 | } // namespace burl | |||
| 74 | } // namespace boost | |||
| 75 |