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 250 of file XrdHttpTpcTPC.cc.

251{
252 std::stringstream parser(opaque);
253 std::string sequence;
254 std::stringstream output;
255 bool first = true;
256 while (getline(parser, sequence, '&')) {
257 if (sequence.empty()) {continue;}
258 size_t equal_pos = sequence.find('=');
259 char *val = NULL;
260 if (equal_pos != std::string::npos)
261 val = curl_easy_escape(curl, sequence.c_str() + equal_pos + 1, sequence.size() - equal_pos - 1);
262 // Do not emit parameter if value exists and escaping failed.
263 if (!val && equal_pos != std::string::npos) {continue;}
264
265 if (!first) output << "&";
266 first = false;
267 output << sequence.substr(0, equal_pos);
268 if (val) {
269 output << "=" << val;
270 curl_free(val);
271 }
272 }
273 return output.str();
274}
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 331 of file XrdHttpTpcTPC.cc.

332{
333 const std::string allowed_schemes[] = { "https://", "http://" };
334
335 for (const auto& s : allowed_schemes)
336 if (url.compare(0, s.size(), s) == 0)
337 return true;
338
339 return false;
340}

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 320 of file XrdHttpTpcTPC.cc.

321{
322 const std::string replace_schemes[] = { "davs://", "s3://", "s3s://" };
323
324 for (const auto& s : replace_schemes)
325 if (url.compare(0, s.size(), s) == 0)
326 return "https://" + url.substr(s.size());
327
328 return url;
329}

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 1204 of file XrdHttpTpcTPC.cc.

1204 {
1205 if (curl_global_init(CURL_GLOBAL_DEFAULT)) {
1206 log->Emsg("TPCInitialize", "libcurl failed to initialize");
1207 return NULL;
1208 }
1209
1210 TPCHandler *retval{NULL};
1211 if (!config) {
1212 log->Emsg("TPCInitialize", "TPC handler requires a config filename in order to load");
1213 return NULL;
1214 }
1215 try {
1216 log->Emsg("TPCInitialize", "Will load configuration for the TPC handler from", config);
1217 retval = new TPCHandler(log, config, myEnv);
1218 } catch (std::runtime_error &re) {
1219 log->Emsg("TPCInitialize", "Encountered a runtime failure when loading ", re.what());
1220 //printf("Provided env vars: %p, XrdInet*: %p\n", myEnv, myEnv->GetPtr("XrdInet*"));
1221 }
1222 return retval;
1223}
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: