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 47 of file XrdHttpTpcTPC.hh.

Constructor & Destructor Documentation

◆ TPCHandler()

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

Definition at line 219 of file XrdHttpTpcTPC.cc.

219  :
220  m_desthttps(false),
221  m_fixed_route(false),
222  m_timeout(60),
223  m_first_timeout(120),
224  m_log(log->logger(), "TPC_"),
225  m_sfs(NULL),
226  m_request_manager(*myEnv, *log)
227 {
228  if (!Configure(config, myEnv)) {
229  throw std::runtime_error("Failed to configure the HTTP third-party-copy handler.");
230  }
231 
232 // Extract out the TPC monitoring object (we share it with xrootd).
233 //
234  XrdXrootdGStream *gs = (XrdXrootdGStream*)myEnv->GetPtr("Tpc.gStream*");
235  if (gs)
236  TPCLogRecord::tpcMonitor = new XrdXrootdTpcMon("http",log->logger(),*gs);
237 }
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 211 of file XrdHttpTpcTPC.cc.

211  {
212  m_sfs = NULL;
213 }

Member Function Documentation

◆ Init()

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

Initializes the external request handler.

Implements XrdHttpExtHandler.

Definition at line 55 of file XrdHttpTpcTPC.hh.

55 {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 164 of file XrdHttpTpcTPC.cc.

164  {
165  return !strcmp(verb, "COPY") || !strcmp(verb, "OPTIONS");
166 }

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

183  {
184  if (req.verb == "OPTIONS") {
185  return ProcessOptionsReq(req);
186  }
187  auto header = XrdOucTUtils::caseInsensitiveFind(req.headers,"credential");
188  if (header != req.headers.end()) {
189  if (header->second != "none") {
190  m_log.Emsg("ProcessReq", "COPY requested an unsupported credential type: ", header->second.c_str());
191  return req.SendSimpleResp(400, NULL, NULL, "COPY requestd an unsupported Credential type", 0);
192  }
193  }
194  header = XrdOucTUtils::caseInsensitiveFind(req.headers,"source");
195  if (header != req.headers.end()) {
196  std::string src = PrepareURL(header->second);
197  return ProcessPullReq(src, req);
198  }
199  header = XrdOucTUtils::caseInsensitiveFind(req.headers,"destination");
200  if (header != req.headers.end()) {
201  return ProcessPushReq(header->second, req);
202  }
203  m_log.Emsg("ProcessReq", "COPY verb requested but no source or destination specified.");
204  return req.SendSimpleResp(400, NULL, NULL, "No Source or Destination specified", 0);
205 }
static std::string PrepareURL(const std::string &input)
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, 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 56 of file XrdHttpTpcTPC.hh.

Referenced by XrdHttpTpcUtils::prepareOpenURL().


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