XRootD
Loading...
Searching...
No Matches
XrdClHttp Namespace Reference

Namespaces

namespace  HeaderBuilder
namespace  ThirdPartyCopyOpTypes

Classes

struct  ChecksumEntry
class  ChecksumInfo
class  ConnectionCallout
class  CurlChecksumOp
class  CurlCopyOp
class  CurlDeleteOp
class  CurlListdirOp
class  CurlMkcolOp
class  CurlOpenOp
class  CurlOperation
class  CurlOptionsOp
class  CurlPgReadOp
class  CurlPrefetchOpenOp
class  CurlPutOp
class  CurlQueryOp
class  CurlReadOp
class  CurlStatOp
class  CurlTapeOp
class  CurlTapePrepareOp
class  CurlTapeQueryOp
class  CurlVectorReadOp
class  CurlWorker
class  DeleteResponseInfo
class  DirectoryListResponse
class  Factory
class  File
class  Filesystem
class  HandlerQueue
class  HeaderCallout
class  HeaderParser
class  MkdirResponseInfo
class  OpenResponseInfo
class  QueryResponse
class  ReadResponseInfo
class  ResponseInfo
class  StatResponse
struct  TapeHttpRequest
class  TapeOperation
class  VerbsCache

Typedefs

using CreateConnCalloutType = ConnectionCallout *(*)(const std::string &, const ResponseInfo &)

Enumerations

enum class  ChecksumType {
  kADLER32 ,
  kCRC32 ,
  kCRC32C ,
  kMD5 ,
  kSHA1 ,
  kSHA256 ,
  kAll ,
  kUnknown
}
enum class  HttpVerb {
  COPY ,
  DELETE ,
  HEAD ,
  GET ,
  POST ,
  MKCOL ,
  OPTIONS ,
  PROPFIND ,
  PUT ,
  Count
}
enum class  TpcMode {
  Pull ,
  Push
}

Functions

void ConfigureHandle (CURL *curl, bool verbose)
std::string GetBearerToken (XrdCl::Log *logger=nullptr)
size_t GetChecksumLength (ChecksumType ctype)
CURL * GetHandle (bool verbose)
ChecksumType GetTypeFromString (const std::string &str)
const std::string GetTypeString (ChecksumType ctype)
std::pair< uint16_t, uint32_t > HTTPStatusConvert (unsigned status)
bool HTTPStatusIsError (unsigned status)
void InjectBearerToken (const XrdCl::URL &url, std::vector< std::pair< std::string, std::string > > &headers, XrdCl::Log *logger=nullptr)
std::string_view ltrim_view (const std::string_view &input_view)
std::string MarshalDuration (const struct timespec &timeout)
bool ParseTimeout (const std::string &duration, struct timespec &, std::string &errmsg)
bool ParseTokenFile (const std::string &token_file, CurlCopyOp::Headers &src_hdrs, CurlCopyOp::Headers &dst_hdrs)
bool ShouldUseBearerToken (const std::string &protocols, bool hasX509Credential, bool hasBearerToken)
static std::optional< std::size_t > stat_size (HandlerQueue &queue, const std::string &url, const CurlCopyOp::Headers &hdrs, time_t timeout, XrdCl::Log *log, const char *what)
std::string TapeProblemResponse (long statusCode, const std::string &body)
std::string_view trim_view (const std::string_view &input_view)

Variables

constexpr size_t g_max_checksum_length = 32
const uint64_t kLogXrdClHttp = 73173

Class Documentation

◆ XrdClHttp::ChecksumEntry

struct XrdClHttp::ChecksumEntry

Definition at line 103 of file XrdClHttpChecksum.hh.

Collaboration diagram for XrdClHttp::ChecksumEntry:
Class Members
ChecksumType type {ChecksumType::kUnknown}
array< unsigned char, g_max_checksum_length > value

◆ XrdClHttp::TapeHttpRequest

struct XrdClHttp::TapeHttpRequest

Definition at line 41 of file XrdClHttpTape.hh.

Collaboration diagram for XrdClHttp::TapeHttpRequest:
Class Members
string body
HttpVerb method = HttpVerb::GET
string url

Typedef Documentation

◆ CreateConnCalloutType

using XrdClHttp::CreateConnCalloutType = ConnectionCallout *(*)(const std::string &, const ResponseInfo &)

Definition at line 69 of file XrdClHttpConnectionCallout.hh.

Enumeration Type Documentation

◆ ChecksumType

enum class XrdClHttp::ChecksumType
strong
Enumerator
kADLER32 
kCRC32 
kCRC32C 
kMD5 
kSHA1 
kSHA256 
kAll 
kUnknown 

Definition at line 33 of file XrdClHttpChecksum.hh.

33 {
35 kCRC32,
36 kCRC32C,
37 kMD5,
38 kSHA1,
39 kSHA256,
40 kAll, // Select any supported checksum.
41 kUnknown, // Indicates an unset value; `kUnknown - 1` is used in for-loops to iterate through all checksums.
42};

◆ HttpVerb

enum class XrdClHttp::HttpVerb
strong
Enumerator
COPY 
DELETE 
HEAD 
GET 
POST 
MKCOL 
OPTIONS 
PROPFIND 
PUT 
Count 

Definition at line 30 of file XrdClHttpVerb.hh.

◆ TpcMode

enum class XrdClHttp::TpcMode
strong
Enumerator
Pull 
Push 

Definition at line 889 of file XrdClHttpOps.hh.

Function Documentation

◆ ConfigureHandle()

void XrdClHttp::ConfigureHandle ( CURL * curl,
bool verbose )

Definition at line 776 of file XrdClHttpUtil.cc.

776 {
777 curl_easy_setopt(curl, CURLOPT_USERAGENT, "xrdcl-http/" XrdVERSION);
778 curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, DumpHeader);
779 curl_easy_setopt(curl, CURLOPT_DEBUGDATA, XrdCl::DefaultEnv::GetLog());
780 if (verbose)
781 curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
782
783 auto env = XrdCl::DefaultEnv::GetEnv();
784 std::string ca_file;
785 if (!env->GetString("HttpCertFile", ca_file) || ca_file.empty()) {
786 char *x509_ca_file = getenv("X509_CERT_FILE");
787 if (x509_ca_file) {
788 ca_file = std::string(x509_ca_file);
789 }
790 }
791 if (!ca_file.empty()) {
792 curl_easy_setopt(curl, CURLOPT_CAINFO, ca_file.c_str());
793 }
794 std::string ca_dir;
795 if (!env->GetString("HttpCertDir", ca_dir) || ca_dir.empty()) {
796 char *x509_ca_dir = getenv("X509_CERT_DIR");
797 if (x509_ca_dir) {
798 ca_dir = std::string(x509_ca_dir);
799 }
800 }
801 if (!ca_dir.empty()) {
802 curl_easy_setopt(curl, CURLOPT_CAPATH, ca_dir.c_str());
803 }
804
805 curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 32*1024);
806}
static Log * GetLog()
Get default log.
static Env * GetEnv()
Get default client environment.

References XrdCl::DefaultEnv::GetEnv(), and XrdCl::DefaultEnv::GetLog().

Referenced by GetHandle(), and XrdClHttp::CurlOperation::SetupNextRequest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBearerToken()

std::string XrdClHttp::GetBearerToken ( XrdCl::Log * logger = nullptr)

Definition at line 117 of file XrdClHttpUtil.cc.

118{
119 auto env = XrdCl::DefaultEnv::GetEnv();
120 if (!env) return {};
121
122 std::string token;
123 if (!env->GetString("BearerToken", token) || token.empty()) {
124 env->ImportString("BearerToken", "BEARER_TOKEN");
125 env->GetString("BearerToken", token);
126 }
127 if (!token.empty()) {
128 XrdCl::Utils::Trim(token);
129 return token;
130 }
131
132 std::string token_file;
133 if (!env->GetString("BearerTokenFile", token_file) || token_file.empty()) {
134 env->ImportString("BearerTokenFile", "BEARER_TOKEN_FILE");
135 env->GetString("BearerTokenFile", token_file);
136 }
137 if (token_file.empty()) return {};
138
139 std::ifstream input(token_file);
140 if (!input) return {};
141 std::getline(input, token);
142 XrdCl::Utils::Trim(token);
143 return token;
144}
static void Trim(std::string &str)
Trim a string.

References XrdCl::DefaultEnv::GetEnv(), and XrdCl::Utils::Trim().

Referenced by InjectBearerToken().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChecksumLength()

size_t XrdClHttp::GetChecksumLength ( ChecksumType ctype)
inline

Definition at line 65 of file XrdClHttpChecksum.hh.

65 {
66 switch (ctype) {
70 return 4;
72 return 16;
74 return 20;
76 return 32;
77 case ChecksumType::kAll: // fallthrough
79 return 0;
80 }
81 return 0;
82}

References GetChecksumLength(), kADLER32, kAll, kCRC32, kCRC32C, kMD5, kSHA1, kSHA256, and kUnknown.

Referenced by GetChecksumLength(), XrdClHttp::HeaderParser::ParseDigest(), and XrdClHttp::CurlChecksumOp::Success().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetHandle()

CURL * XrdClHttp::GetHandle ( bool verbose)

Definition at line 809 of file XrdClHttpUtil.cc.

809 {
810 auto result = curl_easy_init();
811 if (result == nullptr) {
812 return result;
813 }
814
815 XrdClHttp::ConfigureHandle(result, verbose);
816
817 return result;
818}
void ConfigureHandle(CURL *curl, bool verbose)

References ConfigureHandle().

Here is the call graph for this function:

◆ GetTypeFromString()

ChecksumType XrdClHttp::GetTypeFromString ( const std::string & str)
inline

Definition at line 84 of file XrdClHttpChecksum.hh.

84 {
85 if (str == "adler" || str == "adler32") {
87 } else if (str == "crc32") {
89 } else if (str == "crc32c") {
91 } else if (str == "md5") {
92 return ChecksumType::kMD5;
93 } else if (str == "sha1") {
95 } else if (str == "sha256") {
97 }
99}

References GetTypeFromString(), kADLER32, kCRC32, kCRC32C, kMD5, kSHA1, kSHA256, and kUnknown.

Referenced by GetTypeFromString(), and XrdClHttp::Filesystem::Query().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTypeString()

const std::string XrdClHttp::GetTypeString ( ChecksumType ctype)
inline

Definition at line 44 of file XrdClHttpChecksum.hh.

44 {
45 switch (ctype) {
47 return "adler32";
49 return "crc32";
51 return "crc32c";
53 return "md5";
55 return "sha1";
57 return "sha256";
58 case ChecksumType::kAll: // fallthrough
60 return "unknown";
61 }
62 return "unknown";
63}

References GetTypeString(), kADLER32, kAll, kCRC32, kCRC32C, kMD5, kSHA1, kSHA256, and kUnknown.

Referenced by GetTypeString(), and XrdClHttp::CurlChecksumOp::Success().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HTTPStatusConvert()

std::pair< uint16_t, uint32_t > XrdClHttp::HTTPStatusConvert ( unsigned status)

Definition at line 208 of file XrdClHttpUtil.cc.

208 {
209 switch (status) {
210 case 400: // Bad Request
211 return std::make_pair(XrdCl::errErrorResponse, kXR_InvalidRequest);
212 case 401: // Unauthorized (needs authentication)
213 return std::make_pair(XrdCl::errErrorResponse, kXR_NotAuthorized);
214 case 402: // Payment Required
215 case 403: // Forbidden (failed authorization)
216 return std::make_pair(XrdCl::errErrorResponse, kXR_NotAuthorized);
217 case 404:
218 return std::make_pair(XrdCl::errErrorResponse, kXR_NotFound);
219 case 405: // Method not allowed
220 return std::make_pair(XrdCl::errErrorResponse, kXR_Unsupported);
221 case 406: // Not acceptable
222 return std::make_pair(XrdCl::errErrorResponse, kXR_InvalidRequest);
223 case 407: // Proxy Authentication Required
224 return std::make_pair(XrdCl::errErrorResponse, kXR_NotAuthorized);
225 case 408: // Request timeout
226 return std::make_pair(XrdCl::errErrorResponse, kXR_ReqTimedOut);
227 case 409: // Conflict
228 return std::make_pair(XrdCl::errErrorResponse, kXR_Conflict);
229 case 410: // Gone
230 return std::make_pair(XrdCl::errErrorResponse, kXR_NotFound);
231 case 411: // Length required
232 case 412: // Precondition failed
233 case 413: // Payload too large
234 case 414: // URI too long
235 case 415: // Unsupported Media Type
236 case 416: // Range Not Satisfiable
237 case 417: // Expectation Failed
238 case 418: // I'm a teapot
239 return std::make_pair(XrdCl::errErrorResponse, kXR_InvalidRequest);
240 case 421: // Misdirected Request
241 case 422: // Unprocessable Content
242 return std::make_pair(XrdCl::errErrorResponse, kXR_InvalidRequest);
243 case 423: // Locked
244 return std::make_pair(XrdCl::errErrorResponse, kXR_FileLocked);
245 case 424: // Failed Dependency
246 case 425: // Too Early
247 case 426: // Upgrade Required
248 case 428: // Precondition Required
249 return std::make_pair(XrdCl::errErrorResponse, kXR_InvalidRequest);
250 case 429: // Too Many Requests
251 return std::make_pair(XrdCl::errErrorResponse, kXR_Overloaded);
252 case 431: // Request Header Fields Too Large
253 return std::make_pair(XrdCl::errErrorResponse, kXR_InvalidRequest);
254 case 451: // Unavailable For Legal Reasons
255 return std::make_pair(XrdCl::errErrorResponse, kXR_Impossible);
256 case 500: // Internal Server Error
257 return std::make_pair(XrdCl::errErrorResponse, kXR_ServerError);
258 case 501: // Not Implemented
259 return std::make_pair(XrdCl::errErrorResponse, kXR_Unsupported);
260 case 502: // Bad Gateway
261 return std::make_pair(XrdCl::errErrorResponse, kXR_ServerError);
262 case 503: // Service Unavailable
263 return std::make_pair(XrdCl::errErrorResponse, kXR_Overloaded);
264 case 504: // Gateway Timeout
265 return std::make_pair(XrdCl::errErrorResponse, kXR_ReqTimedOut);
266 case 507: // Insufficient Storage
267 return std::make_pair(XrdCl::errErrorResponse, kXR_overQuota);
268 case 508: // Loop Detected
269 case 510: // Not Extended
270 case 511: // Network Authentication Required
271 return std::make_pair(XrdCl::errErrorResponse, kXR_ServerError);
272 }
273 return std::make_pair(XrdCl::errUnknown, status);
274}
@ kXR_InvalidRequest
@ kXR_Impossible
@ kXR_NotAuthorized
@ kXR_NotFound
@ kXR_FileLocked
@ kXR_overQuota
@ kXR_Unsupported
@ kXR_Conflict
@ kXR_ServerError
@ kXR_Overloaded
@ kXR_ReqTimedOut
const uint16_t errUnknown
Unknown error.
const uint16_t errErrorResponse

References XrdCl::errErrorResponse, XrdCl::errUnknown, kXR_Conflict, kXR_FileLocked, kXR_Impossible, kXR_InvalidRequest, kXR_NotAuthorized, kXR_NotFound, kXR_Overloaded, kXR_overQuota, kXR_ReqTimedOut, kXR_ServerError, and kXR_Unsupported.

Referenced by XrdClHttp::CurlWorker::Run().

Here is the caller graph for this function:

◆ HTTPStatusIsError()

bool XrdClHttp::HTTPStatusIsError ( unsigned status)

Definition at line 113 of file XrdClHttpUtil.cc.

113 {
114 return (status < 100) || (status >= 400);
115}

Referenced by XrdClHttp::CurlWorker::Run(), and XrdClHttp::CurlVectorReadOp::Write().

Here is the caller graph for this function:

◆ InjectBearerToken()

void XrdClHttp::InjectBearerToken ( const XrdCl::URL & url,
std::vector< std::pair< std::string, std::string > > & headers,
XrdCl::Log * logger = nullptr )

Definition at line 165 of file XrdClHttpUtil.cc.

169{
170 if(url.GetParams().count("authz")) return;
171 for(const auto &header : headers)
172 {
173 if(header.first == "Authorization") return;
174 }
175
176 const std::string token = GetBearerToken(logger);
177 if(token.empty()) return;
178
179 bool hasX509Credential = false;
180 auto env = XrdCl::DefaultEnv::GetEnv();
181 if(env)
182 {
183 int disableX509 = 0;
184 std::string certificate;
185 hasX509Credential =
186 env->GetInt("HttpDisableX509", disableX509)
187 && !disableX509
188 && env->GetString("HttpClientCertFile", certificate)
189 && !certificate.empty();
190 }
191
192 const char *configuredProtocols = std::getenv("XrdSecPROTOCOL");
193 if(!ShouldUseBearerToken(configuredProtocols ? configuredProtocols : "",
194 hasX509Credential, true))
195 {
196 return;
197 }
198
199 if(logger)
200 {
201 logger->Debug(kLogXrdClHttp,
202 "Injecting bearer token from environment for %s",
203 url.GetURL().c_str());
204 }
205 headers.emplace_back("Authorization", "Bearer " + token);
206}
void Debug(uint64_t topic, const char *format,...)
Print a debug message.
Definition XrdClLog.cc:282
std::string GetURL() const
Get the URL.
Definition XrdClURL.hh:86
const ParamsMap & GetParams() const
Get the URL params.
Definition XrdClURL.hh:244
bool ShouldUseBearerToken(const std::string &protocols, bool hasX509Credential, bool hasBearerToken)
const uint64_t kLogXrdClHttp
std::string GetBearerToken(XrdCl::Log *logger=nullptr)

References XrdCl::Log::Debug(), GetBearerToken(), XrdCl::DefaultEnv::GetEnv(), XrdCl::URL::GetParams(), XrdCl::URL::GetURL(), kLogXrdClHttp, and ShouldUseBearerToken().

Referenced by XrdClHttp::CurlOperation::FinishSetup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ltrim_view()

std::string_view XrdClHttp::ltrim_view ( const std::string_view & input_view)

Definition at line 766 of file XrdClHttpUtil.cc.

766 {
767 for (size_t idx = 0; idx < input_view.size(); idx++) {
768 if (!isspace(input_view[idx])) {
769 return input_view.substr(idx);
770 }
771 }
772 return "";
773}

Referenced by trim_view().

Here is the caller graph for this function:

◆ MarshalDuration()

std::string XrdClHttp::MarshalDuration ( const struct timespec & timeout)

Definition at line 111 of file XrdClHttpParseTimeout.cc.

112{
113 if (duration.tv_sec == 0 && duration.tv_nsec == 0) {return "0s";}
114
115 std::string result = duration.tv_sec != 0 ? std::to_string(duration.tv_sec) + "s" : "";
116 if (duration.tv_nsec) {
117 result += std::to_string(duration.tv_nsec / 1'000'000) + "ms";
118 }
119 return result;
120}

Referenced by XrdClHttp::File::Open().

Here is the caller graph for this function:

◆ ParseTimeout()

bool XrdClHttp::ParseTimeout ( const std::string & duration,
struct timespec & result,
std::string & errmsg )

Definition at line 26 of file XrdClHttpParseTimeout.cc.

26 {
27
28 if (duration.empty()) {
29 errmsg = "cannot parse empty string as a time duration";
30 return false;
31 }
32 if (duration == "0") {
33 result = {0, 0};
34 return true;
35 }
36 struct timespec ts = {0, 0};
37 auto strValue = duration;
38 while (!strValue.empty()) {
39 std::size_t pos;
40 double value;
41 try {
42 value = std::stod(strValue, &pos);
43 } catch (std::invalid_argument const &exc) {
44 errmsg = "Invalid number provided as timeout: " + strValue;
45 return false;
46 } catch (std::out_of_range const &exc) {
47 errmsg = "Provided timeout out of representable range: " + std::string(exc.what());
48 return false;
49 }
50 if (value < 0) {
51 errmsg = "Provided timeout was negative";
52 return false;
53 }
54 strValue = strValue.substr(pos);
55 char unit[3] = {'\0', '\0', '\0'};
56 if (!strValue.empty()) {
57 unit[0] = strValue[0];
58 if (unit[0] >= '0' && unit[0] <= '9') {unit[0] = '\0';}
59 }
60 if (strValue.size() > 1) {
61 unit[1] = strValue[1];
62 if (unit[1] >= '0' && unit[1] <= '9') {unit[1] = '\0';}
63 }
64 if (!strncmp(unit, "ns", 2)) {
65 ts.tv_nsec += value;
66 } else if (!strncmp(unit, "us", 2)) {
67 auto value_s = (static_cast<long long>(value)) / 1'000'000;
68 ts.tv_sec += value_s;
69 value -= value_s * 1'000'000;
70 ts.tv_nsec += value * 1'000'000;
71 } else if (!strncmp(unit, "ms", 2)) {
72 auto value_s = (static_cast<long long>(value)) / 1'000;
73 ts.tv_sec += value_s;
74 value -= value_s * 1'000;
75 ts.tv_nsec += value * 1'000'000;
76 } else if (!strncmp(unit, "s", 1)) {
77 auto value_s = (static_cast<long long>(value));
78 ts.tv_sec += value_s;
79 value -= value_s;
80 ts.tv_nsec += value * 1'000'000'000;
81 } else if (!strncmp(unit, "m", 1)) {
82 value *= 60;
83 auto value_s = (static_cast<long long>(value));
84 ts.tv_sec += value_s;
85 value -= value_s;
86 ts.tv_nsec += value * 1'000'000'000;
87 } else if (!strncmp(unit, "h", 1)) {
88 value *= 3600;
89 auto value_s = (static_cast<long long>(value));
90 ts.tv_sec += value_s;
91 value -= value_s;
92 ts.tv_nsec += value * 1'000'000'000;
93 } else if (strlen(unit) > 0) {
94 errmsg = "Unknown unit in duration: " + std::string(unit);
95 return false;
96 } else {
97 errmsg = "Unit missing from duration: " + duration;
98 return false;
99 }
100 if (ts.tv_nsec > 1'000'000'000) {
101 ts.tv_sec += ts.tv_nsec / 1'000'000'000;
102 ts.tv_nsec = ts.tv_nsec % 1'000'000'000;
103 }
104 strValue = strValue.substr(strlen(unit));
105 }
106 result.tv_nsec = ts.tv_nsec;
107 result.tv_sec = ts.tv_sec;
108 return true;
109}

Referenced by XrdClHttp::File::ParseHeaderTimeout(), and XrdClHttp::File::SetProperty().

Here is the caller graph for this function:

◆ ParseTokenFile()

bool XrdClHttp::ParseTokenFile ( const std::string & token_file,
CurlCopyOp::Headers & src_hdrs,
CurlCopyOp::Headers & dst_hdrs )

Definition at line 13 of file XrdClHttpTokenFileParser.cc.

16{
18
19 std::ifstream file(token_file);
20
21 if (!file.is_open())
22 {
23 log->Warning(kLogXrdClHttp, "Failed to open token file");
24 return false;
25 }
26
27 constexpr std::streamsize max_token_file_size = 10 * 1024;
28
29 std::string content(max_token_file_size, '\0');
30 file.read(&content[0], max_token_file_size);
31 content.resize(file.gcount());
32
33 std::string src_token;
34 std::string dst_token;
35
36 if (const auto json = nlohmann::json::parse(content, nullptr, false); json.is_object())
37 {
38 const auto read_token = [&json, log] (const char *key, std::string &token)
39 {
40 if (const auto value = json.find(key); value != json.end() && value->is_string() && !value->get_ref<const std::string &>().empty())
41 token = value->get_ref<const std::string &>();
42 else
43 log->Warning(kLogXrdClHttp, "Property '%s' of the token file is not a non-empty string", key);
44 };
45
46 read_token("src", src_token);
47 read_token("dst", dst_token);
48 }
49 else
50 {
51 std::istringstream lines(content);
52 std::getline(lines, src_token);
53 std::getline(lines, dst_token);
54 }
55
56 if (src_token.empty() && dst_token.empty())
57 {
58 log->Warning(kLogXrdClHttp, "Token file holds neither a <src> nor a <dst> token");
59 return false;
60 }
61
62 const auto add_token = [] (CurlCopyOp::Headers &headers, const std::string &token)
63 {
64 if (!token.empty())
65 headers.emplace_back("Authorization"s, "Bearer "s + token);
66 };
67
68 add_token(src_hdrs, src_token);
69 add_token(dst_hdrs, dst_token);
70
71 return true;
72}
nlohmann::json json
std::vector< std::pair< std::string, std::string > > Headers
Handle diagnostics.
Definition XrdClLog.hh:101
void Warning(uint64_t topic, const char *format,...)
Report a warning.
Definition XrdClLog.cc:248

References XrdCl::DefaultEnv::GetLog(), kLogXrdClHttp, and XrdCl::Log::Warning().

Referenced by XrdClHttp::Filesystem::ThirdPartyCopy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShouldUseBearerToken()

bool XrdClHttp::ShouldUseBearerToken ( const std::string & protocols,
bool hasX509Credential,
bool hasBearerToken )

Definition at line 146 of file XrdClHttpUtil.cc.

149{
150 if(protocols.empty()) return hasBearerToken;
151
152 std::vector<std::string> requested;
153 XrdCl::Utils::splitString(requested, protocols, ",");
154 for(auto protocol : requested)
155 {
156 XrdCl::Utils::Trim(protocol);
157 std::transform(protocol.begin(), protocol.end(), protocol.begin(),
158 [](unsigned char c) { return std::tolower(c); });
159 if(protocol == "gsi" && hasX509Credential) return false;
160 if(protocol == "ztn" && hasBearerToken) return true;
161 }
162 return false;
163}
static void splitString(Container &result, const std::string &input, const std::string &delimiter)
Split a string.
Definition XrdClUtils.hh:56

References XrdCl::Utils::splitString(), and XrdCl::Utils::Trim().

Referenced by InjectBearerToken().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stat_size()

std::optional< std::size_t > XrdClHttp::stat_size ( HandlerQueue & queue,
const std::string & url,
const CurlCopyOp::Headers & hdrs,
time_t timeout,
XrdCl::Log * log,
const char * what )
static

Definition at line 430 of file XrdClHttpFilesystem.cc.

436{
437 try
438 {
439 const auto callout = std::make_shared<ExtraHeaderCallout>(hdrs);
440 const auto rh = std::make_shared<SyncResponseHandler>();
441 const auto op = std::make_shared<StatOp>(rh.get(), url, timespec{timeout, 0}, log, true, nullptr, callout.get());
442
443 // The queue may run the operation after this function returns, thus
444 // the operation keeps its handler and header callout alive.
445 queue.Produce(std::shared_ptr<StatOp>(op.get(), [callout, rh, op](auto){}));
446
447 if (!rh->wait(std::chrono::seconds(timeout)))
448 log->Warning(kLogXrdClHttp, "Failed to stat the %s: Operation timed out", what);
449 else if (!op->IsDone() || op->HasFailed())
450 log->Debug(kLogXrdClHttp, "Failed to stat the %s", what);
451 else
452 return static_cast<std::size_t>(op->GetStatInfo().first);
453 }
454 catch (const std::exception &e) {
455 log->Warning(kLogXrdClHttp, "Failed to stat the %s - %s", what, e.what());
456 }
457
458 return std::nullopt;
459}
void Produce(std::shared_ptr< CurlOperation > handler)

References XrdCl::Log::Debug(), kLogXrdClHttp, XrdClHttp::HandlerQueue::Produce(), stat_size(), and XrdCl::Log::Warning().

Referenced by stat_size(), and XrdClHttp::Filesystem::ThirdPartyCopy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TapeProblemResponse()

std::string XrdClHttp::TapeProblemResponse ( long statusCode,
const std::string & body )

Definition at line 1123 of file XrdClHttpTape.cc.

1124 {
1125 return FormatProblemResponse(statusCode, body);
1126 }

References TapeProblemResponse().

Referenced by XrdClHttp::CurlTapeOp::Fail(), and TapeProblemResponse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ trim_view()

std::string_view XrdClHttp::trim_view ( const std::string_view & input_view)

Definition at line 755 of file XrdClHttpUtil.cc.

755 {
756 auto view = XrdClHttp::ltrim_view(input_view);
757 for (size_t idx = 0; idx < input_view.size(); idx++) {
758 if (!isspace(view[view.size() - 1 - idx])) {
759 return view.substr(0, view.size() - idx);
760 }
761 }
762 return "";
763}
std::string_view ltrim_view(const std::string_view &input_view)

References ltrim_view().

Referenced by XrdClHttp::HeaderParser::ParseDigest().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_max_checksum_length

size_t XrdClHttp::g_max_checksum_length = 32
constexpr

Definition at line 30 of file XrdClHttpChecksum.hh.

◆ kLogXrdClHttp

const uint64_t XrdClHttp::kLogXrdClHttp = 73173

Definition at line 54 of file XrdClHttpUtil.hh.

Referenced by XrdClHttp::Filesystem::Filesystem(), XrdClHttp::HeaderBuilder::Build(), XrdClHttp::File::Close(), XrdClHttp::CurlReadOp::Continue(), XrdClHttp::CurlPutOp::ContinueHandle(), XrdClHttp::CurlReadOp::ContinueHandle(), XrdClHttp::Filesystem::DirList(), XrdClHttp::CurlMkcolOp::Fail(), XrdClHttp::CurlOpenOp::Fail(), XrdClHttp::CurlOperation::Fail(), XrdClHttp::CurlPutOp::Fail(), XrdClHttp::CurlReadOp::Fail(), XrdClHttp::CurlVectorReadOp::Fail(), XrdClHttp::CurlOperation::FailCallback(), XrdClHttp::File::Fcntl(), XrdClHttp::CurlOperation::FinishSetup(), XrdClHttp::CurlStatOp::GetStatInfo(), InjectBearerToken(), XrdClHttp::Filesystem::MkDir(), XrdClHttp::File::Open(), XrdClHttp::File::ParseHeaderTimeout(), ParseTokenFile(), XrdClHttp::CurlPutOp::Pause(), XrdClHttp::CurlReadOp::Pause(), XrdClHttp::File::PgRead(), XrdClHttp::Filesystem::Query(), XrdClHttp::File::Read(), XrdClHttp::CurlOperation::Redirect(), XrdClHttp::Filesystem::Rm(), XrdClHttp::CurlWorker::Run(), XrdClHttp::CurlWorker::RunStatic(), XrdClHttp::File::SetProperty(), XrdClHttp::CurlOperation::Setup(), XrdClHttp::File::Stat(), XrdClHttp::Filesystem::Stat(), stat_size(), XrdClHttp::CurlChecksumOp::Success(), XrdClHttp::CurlDeleteOp::Success(), XrdClHttp::CurlListdirOp::Success(), XrdClHttp::CurlMkcolOp::Success(), XrdClHttp::CurlOpenOp::Success(), XrdClHttp::CurlPutOp::Success(), XrdClHttp::CurlQueryOp::Success(), XrdClHttp::CurlStatOp::SuccessImpl(), XrdClHttp::Filesystem::ThirdPartyCopy(), XrdClHttp::File::VectorRead(), XrdClHttp::CurlOperation::WaitSocketCallback(), XrdClHttp::File::Write(), and XrdClHttp::File::Write().