2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
34 .base_url =
"https://query.wikidata.org/sparql",
35 .default_accept =
"application/sparql-results+json",
36 .rate_hints = {
"polite",
"limit" }
57 const std::string_view override_accept
62 if (!override_accept.empty()) {
63 return std::string { override_accept };
68std::pair<std::string,
bool>
72 = request
.content_type ==
"application/x-www-form-urlencoded";
76 return {
"application/x-www-form-urlencoded",
true };
78 return {
"application/sparql-query",
false };
82 for (
auto& status : statuses) {
83 status.store(0, std::memory_order_relaxed);
92 throw std::invalid_argument(
"unknown service_kind");
97 std::ranges::sort(params, [](
const auto& lhs,
const auto& rhs) {
98 if (lhs.first == rhs.first) {
99 return lhs.second < rhs.second;
101 return lhs.first < rhs.first;
111 const bool has_format
112 = std::ranges::any_of(params, [](
const auto& param) {
113 return param.first ==
"format";
116 params.emplace_back(
"format",
"json");
121 sort_parameters(params);
125 return std::ranges::any_of(query_params, [&](
const auto& p) {
126 return p.first == key;
131 for (
const auto& [fst, snd] : query_params) {
std::string resolve_accept(const sparql_request &request, const service_profile &profile, const std::string_view override_accept)
Resolves the Accept header value for a SPARQL request.
http_method choose_http_method(const sparql_request &request, const std::size_t threshold)
Chooses the appropriate HTTP method for a SPARQL request.
std::pair< std::string, bool > resolve_body_strategy(const sparql_request &request)
Determines the body content and strategy for a SPARQL request.
http_method
HTTP method to use for a request.
void sort_parameters(parameter_list ¶ms)
Sorts the parameter list in-place by key.
service_kind
Identifies supported SPARQL services.
const service_profile & get_service_profile(const service_kind kind)
Retrieve the service profile for a given service kind.
void append_common_params(const service_kind kind, const http_method method, parameter_list ¶ms)
Appends common parameters required for a service and HTTP method.
const service_profile & wdqs_profile()
http_method_hint
Hint for selecting the HTTP method for a request.
bool has_param(std::string_view key) const
Check whether a query parameter with key key exists.
std::string get_param(std::string_view key) const
Retrieve the first value for query parameter key.
network_metrics()
Zero-initialize per-status counters.
Static configuration values describing a remote service.
std::string default_accept