13 #include "opentelemetry/nostd/function_ref.h"
14 #include "opentelemetry/nostd/string_view.h"
15 #include "opentelemetry/version.h"
106 using Byte = uint8_t;
108 using Body = std::vector<Byte>;
112 bool operator()(
const std::string &s1,
const std::string &s2)
const
114 return std::lexicographical_compare(
115 s1.begin(), s1.end(), s2.begin(), s2.end(),
116 [](
char c1,
char c2) { return ::tolower(c1) < ::tolower(c2); });
119 using Headers = std::multimap<std::string, std::string, cmp_ic>;
121 struct HttpSslOptions
126 bool input_ssl_insecure_skip_verify,
151 if (strncmp(url.
data(),
"https:", 6) == 0)
229 using SecondsDecimal = std::chrono::duration<float, std::ratio<1>>;
238 float input_backoff_multiplier)
258 virtual void SetSslOptions(
const HttpSslOptions &options) noexcept = 0;
266 virtual void SetTimeoutMs(std::chrono::milliseconds timeout_ms) noexcept = 0;
270 virtual void EnableLogging(
bool is_log_enabled) noexcept = 0;
272 virtual void SetRetryPolicy(
const RetryPolicy &retry_policy) noexcept = 0;
293 virtual ~Response() = default;
296 class NoopResponse : public Response
305 ) const noexcept
override
312 ) const noexcept
override
325 : response_(
std::
move(res)), session_state_(session_state)
330 if (response_ ==
nullptr)
340 std::unique_ptr<Response> response_;
347 virtual void OnResponse(Response &) noexcept = 0;
357 virtual std::shared_ptr<Request> CreateRequest() noexcept = 0;
361 virtual
bool IsSessionActive() noexcept = 0;
363 virtual
bool CancelSession() noexcept = 0;
365 virtual
bool FinishSession() noexcept = 0;
367 virtual ~Session() = default;
375 virtual bool CancelAllSessions() noexcept = 0;
377 virtual
bool FinishAllSessions() noexcept = 0;
379 virtual
void SetMaxSessionsPerConnection(
std::
size_t max_requests_per_connection) noexcept = 0;
381 virtual ~HttpClient() = default;
392 return Get(url, no_ssl, headers, compression);
397 const Headers &headers = {{
"content-type",
"application/json"}},
401 return Post(url, no_ssl, body, headers, compression);
405 const HttpSslOptions &ssl_options,
410 const HttpSslOptions &ssl_options,
412 const Headers & = {{
"content-type",
"application/json"}},
415 virtual ~HttpClientSync() =
default;