21#ifndef XRDCLHTTPUTIL_HH
22#define XRDCLHTTPUTIL_HH
29#include <condition_variable>
35#include <unordered_map>
68 bool hasX509Credential,
75 std::vector<std::pair<std::string, std::string>> &headers,
79std::string_view
ltrim_view(
const std::string_view &input_view);
82std::string_view
trim_view(
const std::string_view &input_view);
98 bool Parse(
const std::string &headers);
132 m_multipart_sep =
"--" + std::string(sep);
133 m_multipart_byteranges =
true;
144 const std::string &
GetETag()
const {
return m_etag;}
155 std::string_view input,
156 std::array<unsigned char, g_max_checksum_length> &output);
163 static bool validHeaderByte(
unsigned char c);
165 int64_t m_content_length{-1};
166 time_t m_modtime{-1};
167 uint64_t m_response_offset{0};
169 XrdClHttp::ChecksumInfo m_checksums;
171 bool m_recv_all_headers{
false};
172 bool m_recv_status_line{
false};
173 bool m_multipart_byteranges{
false};
175 int m_status_code{-1};
176 std::string m_resp_protocol;
177 std::string m_resp_message;
178 std::string m_location;
179 std::string m_multipart_sep;
181 std::string m_cache_control;
200 void Produce(std::shared_ptr<CurlOperation> handler);
202 std::shared_ptr<CurlOperation>
Consume(std::chrono::steady_clock::duration);
229 bool m_shutdown{
false};
230 std::deque<std::shared_ptr<CurlOperation>> m_ops;
231 static std::atomic<uint64_t> m_ops_consumed;
232 static std::atomic<uint64_t> m_ops_produced;
233 static std::atomic<uint64_t> m_ops_rejected;
234 thread_local static std::vector<CURL*> m_handles;
235 std::condition_variable m_consumer_cv;
236 std::condition_variable m_producer_cv;
238 const static unsigned m_default_max_pending_ops{50};
239 const unsigned m_max_pending_ops{50};
std::shared_ptr< CurlOperation > Consume(std::chrono::steady_clock::duration)
HandlerQueue(unsigned max_pending_ops)
void Produce(std::shared_ptr< CurlOperation > handler)
void RecycleHandle(CURL *)
static std::string GetMonitoringJson()
static unsigned GetDefaultMaxPendingOps()
std::shared_ptr< CurlOperation > TryConsume()
std::unordered_map< std::string, HeaderValues > HeaderMap
std::pair< uint16_t, uint32_t > HTTPStatusConvert(unsigned status)
void InjectBearerToken(const XrdCl::URL &url, std::vector< std::pair< std::string, std::string > > &headers, XrdCl::Log *logger=nullptr)
CURL * GetHandle(bool verbose)
bool HTTPStatusIsError(unsigned status)
bool ShouldUseBearerToken(const std::string &protocols, bool hasX509Credential, bool hasBearerToken)
std::string_view ltrim_view(const std::string_view &input_view)
const uint64_t kLogXrdClHttp
std::string GetBearerToken(XrdCl::Log *logger=nullptr)
void ConfigureHandle(CURL *curl, bool verbose)
std::string_view trim_view(const std::string_view &input_view)