XRootD
Loading...
Searching...
No Matches
XrdHttpTpcTPC.cc File Reference
#include "XrdHttp/XrdHttpExtHandler.hh"
#include "XrdNet/XrdNetAddr.hh"
#include "XrdNet/XrdNetUtils.hh"
#include "XrdOuc/XrdOucEnv.hh"
#include "XrdSec/XrdSecEntity.hh"
#include "XrdSfs/XrdSfsInterface.hh"
#include "XrdSys/XrdSysAtomics.hh"
#include "XrdSys/XrdSysFD.hh"
#include "XrdVersion.hh"
#include "XrdXrootd/XrdXrootdTpcMon.hh"
#include "XrdOuc/XrdOucTUtils.hh"
#include "XrdHttpTpc/XrdHttpTpcUtils.hh"
#include "XrdHttp/XrdHttpUtils.hh"
#include <curl/curl.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <algorithm>
#include <memory>
#include <sstream>
#include <stdexcept>
#include <thread>
#include "XrdHttpTpcState.hh"
#include "XrdHttpTpcStream.hh"
#include "XrdHttpTpcTPC.hh"
#include <fstream>
+ Include dependency graph for XrdHttpTpcTPC.cc:

Go to the source code of this file.

Functions

std::string encode_xrootd_opaque_to_uri (CURL *curl, const std::string &opaque)
 
static bool IsAllowedScheme (const std::string &url)
 
static std::string PrepareURL (const std::string &url)
 
XrdHttpExtHandlerXrdHttpGetExtHandler (XrdSysError *log, const char *config, const char *, XrdOucEnv *myEnv)
 
 XrdVERSIONINFO (XrdHttpGetExtHandler, HttpTPC)
 

Function Documentation

◆ encode_xrootd_opaque_to_uri()

std::string encode_xrootd_opaque_to_uri ( CURL * curl,
const std::string & opaque )

Definition at line 194 of file XrdHttpTpcTPC.cc.

195{
196 std::stringstream parser(opaque);
197 std::string sequence;
198 std::stringstream output;
199 bool first = true;
200 while (getline(parser, sequence, '&')) {
201 if (sequence.empty()) {continue;}
202 size_t equal_pos = sequence.find('=');
203 char *val = NULL;
204 if (equal_pos != std::string::npos)
205 val = curl_easy_escape(curl, sequence.c_str() + equal_pos + 1, sequence.size() - equal_pos - 1);
206 // Do not emit parameter if value exists and escaping failed.
207 if (!val && equal_pos != std::string::npos) {continue;}
208
209 if (!first) output << "&";
210 first = false;
211 output << sequence.substr(0, equal_pos);
212 if (val) {
213 output << "=" << val;
214 curl_free(val);
215 }
216 }
217 return output.str();
218}
void getline(uchar *buff, int blen)

References getline().

+ Here is the call graph for this function:

◆ IsAllowedScheme()

static bool IsAllowedScheme ( const std::string & url)
static

Definition at line 271 of file XrdHttpTpcTPC.cc.

272{
273 const std::string allowed_schemes[] = { "https://", "http://" };
274
275 for (const auto& s : allowed_schemes)
276 if (url.compare(0, s.size(), s) == 0)
277 return true;
278
279 return false;
280}

Referenced by TPC::TPCHandler::ProcessReq().

+ Here is the caller graph for this function:

◆ PrepareURL()

static std::string PrepareURL ( const std::string & url)
static

Definition at line 260 of file XrdHttpTpcTPC.cc.

261{
262 const std::string replace_schemes[] = { "davs://", "s3://", "s3s://" };
263
264 for (const auto& s : replace_schemes)
265 if (url.compare(0, s.size(), s) == 0)
266 return "https://" + url.substr(s.size());
267
268 return url;
269}

Referenced by TPC::TPCHandler::ProcessReq().

+ Here is the caller graph for this function:

◆ XrdHttpGetExtHandler()

XrdHttpExtHandler * XrdHttpGetExtHandler ( XrdSysError * log,
const char * config,
const char * ,
XrdOucEnv * myEnv )

Definition at line 1130 of file XrdHttpTpcTPC.cc.

1130 {
1131 if (curl_global_init(CURL_GLOBAL_DEFAULT)) {
1132 log->Emsg("TPCInitialize", "libcurl failed to initialize");
1133 return NULL;
1134 }
1135
1136 TPCHandler *retval{NULL};
1137 if (!config) {
1138 log->Emsg("TPCInitialize", "TPC handler requires a config filename in order to load");
1139 return NULL;
1140 }
1141 try {
1142 log->Emsg("TPCInitialize", "Will load configuration for the TPC handler from", config);
1143 retval = new TPCHandler(log, config, myEnv);
1144 } catch (std::runtime_error &re) {
1145 log->Emsg("TPCInitialize", "Encountered a runtime failure when loading ", re.what());
1146 //printf("Provided env vars: %p, XrdInet*: %p\n", myEnv, myEnv->GetPtr("XrdInet*"));
1147 }
1148 return retval;
1149}
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)

References XrdSysError::Emsg().

+ Here is the call graph for this function:

◆ XrdVERSIONINFO()

XrdVERSIONINFO ( XrdHttpGetExtHandler ,
HttpTPC  )

References TPC::Pull, and XrdHttpGetExtHandler().

+ Here is the call graph for this function: