Loading...
Searching...
No Matches
XrdHttpTpcUtils Class Reference

`#include <XrdHttpTpcUtils.hh>`

Collaboration diagram for XrdHttpTpcUtils:

## 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)

## Detailed Description

Definition at line 33 of file XrdHttpTpcUtils.hh.

## Member Function Documentation

## prepareOpenURL()

std::string XrdHttpTpcUtils::prepareOpenURL | ( | const std::string & | reqResource,
|  | std::map< std::string, std::string > & | reqHeaders,
|  | const std::map< std::string, std::string > & | hdr2cgimap )

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

We first append oss.task=httptpc opaque info. It is therefore guaranteed that after this function is called, at least one opaque info will be part of the full URL. We need to utilize the full URL (including the query string), not just the resource name. The query portion is hidden in the xrd-http-query header; we take this out and combine it with the resource name. We also append the value of the headers configured in tpc.header2cgi to the resource full URL

One special key is authz; this is always stripped out and copied to the Authorization header (which will later be used for XrdSecEntity). The latter copy is only done if the Authorization header is not already present.

Parameters

  reqResource | the HTTP request resource
  reqHeaders | HTTP request headers that will be modified to contain what is in the authz opaque query if it was provided
  hdr2cgimap | the map containing header keys --> XRootD cgi mapping

Returns
  the XRootD open URL that will contain at least one opaque parameter (oss.task)

Definition at line 27 of file XrdHttpTpcUtils.cc.

{
auto iter = XrdOucTUtils::caseInsensitiveFind(reqHeaders,"xrd-http-query");
std::stringstream opaque;
// https://github.com/xrootd/xrootd/issues/2427 we tell the oss layer that this transfer is a HTTP TPC one
opaque << "?" << TPC::TPCHandler::OSS_TASK_OPAQUE;
if (iter != reqHeaders.end() && !iter->second.empty()) {
std::string token;
std::istringstream requestStream(iter->second);
auto has_authz_header = XrdOucTUtils::caseInsensitiveFind(reqHeaders,"authorization") != reqHeaders.end();
while (std::getline(requestStream, token, '&')) {
if (token.empty()) {
continue;
} else if (!strncmp(token.c_str(), "authz=", 6)) {
if (!has_authz_header) {
reqHeaders["Authorization"] = token.substr(6);
has_authz_header = true;
}
} else {
opaque << "&" << token;
}
}
}
// Append CGI coming from the tpc.header2cgi parameter
for(auto & hdr2cgi : hdr2cgimap) {
auto it = std::find_if(reqHeaders.begin(),reqHeaders.end(),[&hdr2cgi](const auto & elt){
return !strcasecmp(elt.first.c_str(),hdr2cgi.first.c_str());
});
if(it != reqHeaders.end()) {
opaque << "&" << hdr2cgi.second << "=" << it->second;
}
}
return reqResource + opaque.str();
}
TPC::TPCHandler::OSS_TASK_OPAQUE
static constexpr std::string_view OSS_TASK_OPAQUE
Definition XrdHttpTpcTPC.hh:55
XrdOucTUtils::caseInsensitiveFind
static std::map< std::string, T >::const_iterator caseInsensitiveFind(const std::map< std::string, T > &m, const std::string &lowerCaseSearchKey)
Definition XrdOucTUtils.hh:79

References XrdOucTUtils::caseInsensitiveFind(), and TPC::TPCHandler::OSS_TASK_OPAQUE.

Here is the call graph for this function:

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

- XrdHttpTpcUtils.hh
- XrdHttpTpcUtils.cc