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 887 of file XrdClHttpOps.hh.

Function Documentation

◆ ConfigureHandle()

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

Definition at line 763 of file XrdClHttpUtil.cc.

763 {
764 curl_easy_setopt(curl, CURLOPT_USERAGENT, "xrdcl-http/" XrdVERSION);
765 curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, DumpHeader);
766 curl_easy_setopt(curl, CURLOPT_DEBUGDATA, XrdCl::DefaultEnv::GetLog());
767 if (verbose)
768 curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
769
770 auto env = XrdCl::DefaultEnv::GetEnv();
771 std::string ca_file;
772 if (!env->GetString("HttpCertFile", ca_file) || ca_file.empty()) {
773 char *x509_ca_file = getenv("X509_CERT_FILE");
774 if (x509_ca_file) {
775 ca_file = std::string(x509_ca_file);
776 }
777 }
778 if (!ca_file.empty()) {
779 curl_easy_setopt(curl, CURLOPT_CAINFO, ca_file.c_str());
780 }
781 std::string ca_dir;
782 if (!env->GetString("HttpCertDir", ca_dir) || ca_dir.empty()) {
783 char *x509_ca_dir = getenv("X509_CERT_DIR");
784 if (x509_ca_dir) {
785 ca_dir = std::string(x509_ca_dir);
786 }
787 }
788 if (!ca_dir.empty()) {
789 curl_easy_setopt(curl, CURLOPT_CAPATH, ca_dir.c_str());
790 }
791
792 curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 32*1024);
793}
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 116 of file XrdClHttpUtil.cc.

117{
118 auto env = XrdCl::DefaultEnv::GetEnv();
119 if (!env) return {};
120
121 std::string token;
122 if (!env->GetString("BearerToken", token) || token.empty()) {
123 env->ImportString("BearerToken", "BEARER_TOKEN");
124 env->GetString("BearerToken", token);
125 }
126 if (!token.empty()) {
127 XrdCl::Utils::Trim(token);
128 return token;
129 }
130
131 std::string token_file;
132 if (!env->GetString("BearerTokenFile", token_file) || token_file.empty()) {
133 env->ImportString("BearerTokenFile", "BEARER_TOKEN_FILE");
134 env->GetString("BearerTokenFile", token_file);
135 }
136 if (token_file.empty()) return {};
137
138 std::ifstream input(token_file);
139 if (!input) return {};
140 std::getline(input, token);
141 XrdCl::Utils::Trim(token);
142 return token;
143}
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 796 of file XrdClHttpUtil.cc.

796 {
797 auto result = curl_easy_init();
798 if (result == nullptr) {
799 return result;
800 }
801
802 XrdClHttp::ConfigureHandle(result, verbose);
803
804 return result;
805}
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 207 of file XrdClHttpUtil.cc.

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

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

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 164 of file XrdClHttpUtil.cc.

168{
169 if(url.GetParams().count("authz")) return;
170 for(const auto &header : headers)
171 {
172 if(header.first == "Authorization") return;
173 }
174
175 const std::string token = GetBearerToken(logger);
176 if(token.empty()) return;
177
178 bool hasX509Credential = false;
179 auto env = XrdCl::DefaultEnv::GetEnv();
180 if(env)
181 {
182 int disableX509 = 0;
183 std::string certificate;
184 hasX509Credential =
185 env->GetInt("HttpDisableX509", disableX509)
186 && !disableX509
187 && env->GetString("HttpClientCertFile", certificate)
188 && !certificate.empty();
189 }
190
191 const char *configuredProtocols = std::getenv("XrdSecPROTOCOL");
192 if(!ShouldUseBearerToken(configuredProtocols ? configuredProtocols : "",
193 hasX509Credential, true))
194 {
195 return;
196 }
197
198 if(logger)
199 {
200 logger->Debug(kLogXrdClHttp,
201 "Injecting bearer token from environment for %s",
202 url.GetURL().c_str());
203 }
204 headers.emplace_back("Authorization", "Bearer " + token);
205}
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 753 of file XrdClHttpUtil.cc.

753 {
754 for (size_t idx = 0; idx < input_view.size(); idx++) {
755 if (!isspace(input_view[idx])) {
756 return input_view.substr(idx);
757 }
758 }
759 return "";
760}

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 145 of file XrdClHttpUtil.cc.

148{
149 if(protocols.empty()) return hasBearerToken;
150
151 std::vector<std::string> requested;
152 XrdCl::Utils::splitString(requested, protocols, ",");
153 for(auto protocol : requested)
154 {
155 XrdCl::Utils::Trim(protocol);
156 std::transform(protocol.begin(), protocol.end(), protocol.begin(),
157 [](unsigned char c) { return std::tolower(c); });
158 if(protocol == "gsi" && hasX509Credential) return false;
159 if(protocol == "ztn" && hasBearerToken) return true;
160 }
161 return false;
162}
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 742 of file XrdClHttpUtil.cc.

742 {
743 auto view = XrdClHttp::ltrim_view(input_view);
744 for (size_t idx = 0; idx < input_view.size(); idx++) {
745 if (!isspace(view[view.size() - 1 - idx])) {
746 return view.substr(0, view.size() - idx);
747 }
748 }
749 return "";
750}
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 53 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().