XRootD
TPC::TPCHandler Class Reference

#include <XrdHttpTpcTPC.hh>

+ Inheritance diagram for TPC::TPCHandler:
+ Collaboration diagram for TPC::TPCHandler:

Public Member Functions

 TPCHandler (XrdSysError *log, const char *config, XrdOucEnv *myEnv)
 
virtual ~TPCHandler ()
 
virtual int Init (const char *cfgfile)
 Initializes the external request handler. More...
 
virtual bool MatchesPath (const char *verb, const char *path)
 Tells if the incoming path is recognized as one of the paths that have to be processed. More...
 
virtual int ProcessReq (XrdHttpExtReq &req)
 
- Public Member Functions inherited from XrdHttpExtHandler
 XrdHttpExtHandler ()
 Constructor. More...
 
virtual ~XrdHttpExtHandler ()
 Destructor. More...
 

Static Public Attributes

static constexpr std::string_view OSS_TASK_OPAQUE = "oss.task=httptpc"
 

Detailed Description

Definition at line 46 of file XrdHttpTpcTPC.hh.

Constructor & Destructor Documentation

◆ TPCHandler()

TPCHandler::TPCHandler ( XrdSysError log,
const char *  config,
XrdOucEnv myEnv 
)

Definition at line 333 of file XrdHttpTpcTPC.cc.

333  :
334  m_allow_local(false),
335  m_allow_private(true),
336  m_desthttps(false),
337  m_fixed_route(false),
338  m_timeout(60),
339  m_first_timeout(120),
340  m_log(log->logger(), "TPC_"),
341  m_sfs(NULL)
342 {
343  if (!Configure(config, myEnv)) {
344  throw std::runtime_error("Failed to configure the HTTP third-party-copy handler.");
345  }
346 
347 // Extract out the TPC monitoring object (we share it with xrootd).
348 //
349  XrdXrootdGStream *gs = (XrdXrootdGStream*)myEnv->GetPtr("Tpc.gStream*");
350  if (gs)
351  TPCLogRecord::tpcMonitor = new XrdXrootdTpcMon("http",log->logger(),*gs);
352 }
void * GetPtr(const char *varname)
Definition: XrdOucEnv.cc:281
XrdSysLogger * logger(XrdSysLogger *lp=0)
Definition: XrdSysError.hh:141

References XrdOucEnv::GetPtr(), and XrdSysError::logger().

+ Here is the call graph for this function:

◆ ~TPCHandler()

TPCHandler::~TPCHandler ( )
virtual

Definition at line 325 of file XrdHttpTpcTPC.cc.

325  {
326  m_sfs = NULL;
327 }

Member Function Documentation

◆ Init()

virtual int TPC::TPCHandler::Init ( const char *  cfgfile)
inlinevirtual

Initializes the external request handler.

Implements XrdHttpExtHandler.

Definition at line 54 of file XrdHttpTpcTPC.hh.

54 {return 0;}

◆ MatchesPath()

bool TPCHandler::MatchesPath ( const char *  verb,
const char *  path 
)
virtual

Tells if the incoming path is recognized as one of the paths that have to be processed.

Implements XrdHttpExtHandler.

Definition at line 252 of file XrdHttpTpcTPC.cc.

252  {
253  return !strcmp(verb, "COPY") || !strcmp(verb, "OPTIONS");
254 }

◆ ProcessReq()

int TPCHandler::ProcessReq ( XrdHttpExtReq )
virtual

Process an HTTP request and send the response using the calling XrdHttpProtocol instance directly Returns 0 if ok, non0 if errors

Implements XrdHttpExtHandler.

Definition at line 286 of file XrdHttpTpcTPC.cc.

286  {
287  if (req.verb == "OPTIONS") {
288  return ProcessOptionsReq(req);
289  }
290  auto header = XrdOucTUtils::caseInsensitiveFind(req.headers,"credential");
291  if (header != req.headers.end()) {
292  if (header->second != "none") {
293  m_log.Emsg("ProcessReq", "COPY requested an unsupported credential type: ", header->second.c_str());
294  return req.SendSimpleResp(400, NULL, NULL, "COPY requestd an unsupported Credential type", 0);
295  }
296  }
297  header = XrdOucTUtils::caseInsensitiveFind(req.headers,"source");
298  if (header != req.headers.end()) {
299  std::string src = PrepareURL(header->second);
300  if (!IsAllowedScheme(src)) {
301  const char *error_src = "COPY rejected: disallowed scheme in source URL";
302  m_log.Emsg("ProcessReq", error_src, src.c_str());
303  return req.SendSimpleResp(400, NULL, NULL, error_src, 0);
304  }
305  return ProcessPullReq(src, req);
306  }
307  header = XrdOucTUtils::caseInsensitiveFind(req.headers,"destination");
308  if (header != req.headers.end()) {
309  const std::string& dst = header->second;
310  if (!IsAllowedScheme(dst)) {
311  const char *error_dst = "COPY rejected: disallowed scheme in destination URL";
312  m_log.Emsg("ProcessReq", error_dst, dst.c_str());
313  return req.SendSimpleResp(400, NULL, NULL, error_dst, 0);
314  }
315  return ProcessPushReq(header->second, req);
316  }
317  m_log.Emsg("ProcessReq", "COPY verb requested but no source or destination specified.");
318  return req.SendSimpleResp(400, NULL, NULL, "No Source or Destination specified", 0);
319 }
static std::string PrepareURL(const std::string &url)
static bool IsAllowedScheme(const std::string &url)
static std::map< std::string, T >::const_iterator caseInsensitiveFind(const std::map< std::string, T > &m, const std::string &lowerCaseSearchKey)
Definition: XrdOucTUtils.hh:79
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95

References XrdOucTUtils::caseInsensitiveFind(), XrdSysError::Emsg(), XrdHttpExtReq::headers, IsAllowedScheme(), PrepareURL(), XrdHttpExtReq::SendSimpleResp(), and XrdHttpExtReq::verb.

+ Here is the call graph for this function:

Member Data Documentation

◆ OSS_TASK_OPAQUE

constexpr std::string_view TPC::TPCHandler::OSS_TASK_OPAQUE = "oss.task=httptpc"
staticconstexpr

Definition at line 55 of file XrdHttpTpcTPC.hh.

Referenced by XrdHttpTpcUtils::prepareOpenURL().


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