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/XrdXrootdRedirHelper.hh"
#include "XrdXrootd/XrdXrootdTpcMon.hh"
#include "XrdOuc/XrdOucPrivateUtils.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 252 of file XrdHttpTpcTPC.cc.

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

References getline().

Here is the call graph for this function:

◆ IsAllowedScheme()

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

Definition at line 333 of file XrdHttpTpcTPC.cc.

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

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

Here is the caller graph for this function:

◆ PrepareURL()

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

Definition at line 322 of file XrdHttpTpcTPC.cc.

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

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

1238 {
1239 if (curl_global_init(CURL_GLOBAL_DEFAULT)) {
1240 log->Emsg("TPCInitialize", "libcurl failed to initialize");
1241 return NULL;
1242 }
1243
1244 TPCHandler *retval{NULL};
1245 if (!config) {
1246 log->Emsg("TPCInitialize", "TPC handler requires a config filename in order to load");
1247 return NULL;
1248 }
1249 try {
1250 log->Emsg("TPCInitialize", "Will load configuration for the TPC handler from", config);
1251 retval = new TPCHandler(log, config, myEnv);
1252 } catch (std::runtime_error &re) {
1253 log->Emsg("TPCInitialize", "Encountered a runtime failure when loading ", re.what());
1254 //printf("Provided env vars: %p, XrdInet*: %p\n", myEnv, myEnv->GetPtr("XrdInet*"));
1255 }
1256 return retval;
1257}
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: