21#ifndef XRDCLHTTPUTIL_HH
22#define XRDCLHTTPUTIL_HH
29#include <condition_variable>
34#include <unordered_map>
67 bool hasX509Credential,
74 std::vector<std::pair<std::string, std::string>> &headers,
78std::string_view
ltrim_view(
const std::string_view &input_view);
81std::string_view
trim_view(
const std::string_view &input_view);
97 bool Parse(
const std::string &headers);
128 m_multipart_sep =
"--" + std::string(sep);
129 m_multipart_byteranges =
true;
140 const std::string &
GetETag()
const {
return m_etag;}
151 std::string_view input,
152 std::array<unsigned char, g_max_checksum_length> &output);
159 static bool validHeaderByte(
unsigned char c);
161 int64_t m_content_length{-1};
162 uint64_t m_response_offset{0};
164 XrdClHttp::ChecksumInfo m_checksums;
166 bool m_recv_all_headers{
false};
167 bool m_recv_status_line{
false};
168 bool m_multipart_byteranges{
false};
170 int m_status_code{-1};
171 std::string m_resp_protocol;
172 std::string m_resp_message;
173 std::string m_location;
174 std::string m_multipart_sep;
176 std::string m_cache_control;
195 void Produce(std::shared_ptr<CurlOperation> handler);
197 std::shared_ptr<CurlOperation>
Consume(std::chrono::steady_clock::duration);
224 bool m_shutdown{
false};
225 std::deque<std::shared_ptr<CurlOperation>> m_ops;
226 static std::atomic<uint64_t> m_ops_consumed;
227 static std::atomic<uint64_t> m_ops_produced;
228 static std::atomic<uint64_t> m_ops_rejected;
229 thread_local static std::vector<CURL*> m_handles;
230 std::condition_variable m_consumer_cv;
231 std::condition_variable m_producer_cv;
233 const static unsigned m_default_max_pending_ops{50};
234 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)