XRootD
Loading...
Searching...
No Matches
TPC::TPCHandler Class Reference

#include <XrdTpcTPC.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.
 
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.
 
virtual int ProcessReq (XrdHttpExtReq &req)
 
- Public Member Functions inherited from XrdHttpExtHandler
 XrdHttpExtHandler ()
 Constructor.
 
virtual ~XrdHttpExtHandler ()
 Destructor.
 

Detailed Description

Definition at line 42 of file XrdTpcTPC.hh.

Constructor & Destructor Documentation

◆ TPCHandler()

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

Definition at line 304 of file XrdTpcTPC.cc.

304 :
305 m_desthttps(false),
306 m_fixed_route(false),
307 m_timeout(60),
308 m_first_timeout(120),
309 m_log(log->logger(), "TPC_"),
310 m_sfs(NULL)
311{
312 if (!Configure(config, myEnv)) {
313 throw std::runtime_error("Failed to configure the HTTP third-party-copy handler.");
314 }
315
316// Extract out the TPC monitoring object (we share it with xrootd).
317//
318 XrdXrootdGStream *gs = (XrdXrootdGStream*)myEnv->GetPtr("Tpc.gStream*");
319 if (gs)
320 TPCLogRecord::tpcMonitor = new XrdXrootdTpcMon("http",log->logger(),*gs);
321}
void * GetPtr(const char *varname)
Definition XrdOucEnv.cc:263
XrdSysLogger * logger(XrdSysLogger *lp=0)

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

+ Here is the call graph for this function:

◆ ~TPCHandler()

TPCHandler::~TPCHandler ( )
virtual

Definition at line 296 of file XrdTpcTPC.cc.

296 {
297 m_sfs = NULL;
298}

Member Function Documentation

◆ Init()

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

Initializes the external request handler.

Implements XrdHttpExtHandler.

Definition at line 50 of file XrdTpcTPC.hh.

50{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 249 of file XrdTpcTPC.cc.

249 {
250 return !strcmp(verb, "COPY") || !strcmp(verb, "OPTIONS");
251}

◆ 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 268 of file XrdTpcTPC.cc.

268 {
269 if (req.verb == "OPTIONS") {
270 return ProcessOptionsReq(req);
271 }
272 auto header = XrdOucTUtils::caseInsensitiveFind(req.headers,"credential");
273 if (header != req.headers.end()) {
274 if (header->second != "none") {
275 m_log.Emsg("ProcessReq", "COPY requested an unsupported credential type: ", header->second.c_str());
276 return req.SendSimpleResp(400, NULL, NULL, "COPY requestd an unsupported Credential type", 0);
277 }
278 }
279 header = XrdOucTUtils::caseInsensitiveFind(req.headers,"source");
280 if (header != req.headers.end()) {
281 std::string src = PrepareURL(header->second);
282 return ProcessPullReq(src, req);
283 }
284 header = XrdOucTUtils::caseInsensitiveFind(req.headers,"destination");
285 if (header != req.headers.end()) {
286 return ProcessPushReq(header->second, req);
287 }
288 m_log.Emsg("ProcessReq", "COPY verb requested but no source or destination specified.");
289 return req.SendSimpleResp(400, NULL, NULL, "No Source or Destination specified", 0);
290}
static std::string PrepareURL(const std::string &input)
Definition XrdTpcTPC.cc:257
static std::map< std::string, T >::const_iterator caseInsensitiveFind(const std::map< std::string, T > &m, const std::string &lowerCaseSearchKey)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)

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

+ Here is the call graph for this function:

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