XRootD
Loading...
Searching...
No Matches
XrdTpcUtils Class Reference

#include <XrdTpcUtils.hh>

+ Collaboration diagram for XrdTpcUtils:

Static Public Member Functions

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)
 

Detailed Description

Definition at line 28 of file XrdTpcUtils.hh.

Member Function Documentation

◆ 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
reqResourcethe HTTP request resource
theHTTP request headers
hdr2cgimapthe map containing header keys --> XRootD cgi mapping
hasSetOpaqueis 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.

26 {
27 auto iter = XrdOucTUtils::caseInsensitiveFind(reqHeaders,"xrd-http-query");
28 bool found_first_header = false;
29 std::stringstream opaque;
30
31 if (iter != reqHeaders.end() && !iter->second.empty()) {
32 std::string token;
33 std::istringstream requestStream(iter->second);
34 auto has_authz_header = XrdOucTUtils::caseInsensitiveFind(reqHeaders,"authorization") != reqHeaders.end();
35 while (std::getline(requestStream, token, '&')) {
36 if (token.empty()) {
37 continue;
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;
42 }
43 } else {
44 opaque << (found_first_header ? "&" : "?") << token;
45 found_first_header = true;
46 }
47 }
48 }
49
50 // Append CGI coming from the tpc.header2cgi parameter
51 for(auto & hdr2cgi : hdr2cgimap) {
52 auto it = std::find_if(reqHeaders.begin(),reqHeaders.end(),[&hdr2cgi](const auto & elt){
53 return !strcasecmp(elt.first.c_str(),hdr2cgi.first.c_str());
54 });
55 if(it != reqHeaders.end()) {
56 opaque << (found_first_header ? "&" : "?") << hdr2cgi.second << "=" << it->second;
57 found_first_header = true;
58 }
59 }
60 hasSetOpaque = found_first_header;
61 return reqResource + opaque.str();
62}
static std::map< std::string, T >::const_iterator caseInsensitiveFind(const std::map< std::string, T > &m, const std::string &lowerCaseSearchKey)

References XrdOucTUtils::caseInsensitiveFind().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: