#include <XrdTpcUtils.hh>
|
static std::string | prepareOpenURL (const std::string &reqResource, std::map< std::string, std::string > &reqHeaders, const std::map< std::string, std::string > &hdr2cgimap, bool &hasSetOpaque) |
|
Definition at line 28 of file XrdTpcUtils.hh.
◆ prepareOpenURL()
std::string XrdTpcUtils::prepareOpenURL |
( |
const std::string & |
reqResource, |
|
|
std::map< std::string, std::string > & |
reqHeaders, |
|
|
const std::map< std::string, std::string > & |
hdr2cgimap, |
|
|
bool & |
hasSetOpaque |
|
) |
| |
|
static |
Prepares the file XRootD open URL from the request resource, the xrd-http-query header of the HTTP request and the hdr2cgi map passed in parameter
- Parameters
-
reqResource | the HTTP request resource |
the | HTTP request headers |
hdr2cgimap | the map containing header keys --> XRootD cgi mapping |
hasSetOpaque | is set to true if the returned URL contains opaque query, false otherwise |
- Returns
- the XRootD open URL
Definition at line 26 of file XrdTpcUtils.cc.
28 bool found_first_header =
false;
29 std::stringstream opaque;
31 if (iter != reqHeaders.end() && !iter->second.empty()) {
33 std::istringstream requestStream(iter->second);
38 }
else if (!strncmp(token.c_str(),
"authz=", 6)) {
39 if (!has_authz_header) {
40 reqHeaders[
"Authorization"] = token.substr(6);
41 has_authz_header =
true;
43 }
else if (!strncmp(token.c_str(),
"access_token=", 13) && !has_authz_header) {
44 reqHeaders[
"Authorization"] = token.substr(13);
45 has_authz_header =
true;
47 opaque << (found_first_header ?
"&" :
"?") << token;
48 found_first_header =
true;
54 for(
auto & hdr2cgi : hdr2cgimap) {
55 auto it = std::find_if(reqHeaders.begin(),reqHeaders.end(),[&hdr2cgi](
const auto & elt){
56 return !strcasecmp(elt.first.c_str(),hdr2cgi.first.c_str());
58 if(it != reqHeaders.end()) {
59 opaque << (found_first_header ?
"&" :
"?") << hdr2cgi.second <<
"=" << it->second;
60 found_first_header =
true;
63 hasSetOpaque = found_first_header;
64 return reqResource + opaque.str();
void getline(uchar *buff, int blen)
static std::map< std::string, T >::const_iterator caseInsensitiveFind(const std::map< std::string, T > &m, const std::string &lowerCaseSearchKey)
References XrdOucTUtils::caseInsensitiveFind(), and getline().
The documentation for this class was generated from the following files: