71 st = sidMgr->AllocateSID( req->
streamid );
100 msgHandler =
new XRootDMsgHandler( msg, handler, &url, sidMgr, lFileHandler );
121 list->push_back( url );
127 st = postMaster->
Send( url, msg, msgHandler, sendParams.
stateful,
140 sidMgr->ReleaseSID( req->
streamid );
182 msgHandler =
new XRootDMsgHandler( msg, handler, &url, std::shared_ptr<SIDManager>(), lFileHandler );
197 list->push_back( info );
203 st = postMaster->
Redirect( url, msg, msgHandler );
229 env->
GetInt(
"RequestTimeout", requestTimeout );
230 sendParams.
timeout = requestTimeout;
242 env->
GetInt(
"RedirectLimit", redirectLimit );
253 const std::string &newPath,
254 std::string *opathp )
275 for(
int i = 0; i < req->
header.
dlen; ++i, ++path, --length )
285 char *pathWithNull =
new char[length+1];
286 memcpy( pathWithNull, path, length );
287 pathWithNull[length] = 0;
288 std::ostringstream o;
289 o <<
"fake://fake:111/" << pathWithNull;
290 delete [] pathWithNull;
292 URL currentPath( o.str() );
294 MergeCGI( currentCgi, newCgi, replace );
297 *opathp = currentPath.
GetPath();
298 if( !newPath.empty() )
299 currentPath.
SetPath( newPath );
305 uint32_t newDlen = req->
header.
dlen - length + newPathWitParams.size();
311 for(
int i = 0; i < req->
header.
dlen; ++i, ++path )
316 memcpy( path, newPathWitParams.c_str(), newPathWitParams.size() );
324 env->
GetInt(
"PreserveLocateTried", preserveLocateTried );
326 if( !preserveLocateTried )
break;
332 URL::ParamsMap::const_iterator itr = newCgi.find(
"triedrc" );
333 if( itr != newCgi.end() )
334 triedCgi[itr->first] = itr->second;
335 itr = newCgi.find(
"tried" );
336 if( itr != newCgi.end() )
337 triedCgi[itr->first] = itr->second;
342 if( triedCgi.empty() )
break;
353 std::string strpath( path, length );
354 std::ostringstream o;
355 o <<
"fake://fake:111/" << strpath;
357 URL currentPath( o.str() );
359 MergeCGI( currentCgi, triedCgi, replace );
366 uint32_t newDlen = pathWitParams.size();
370 memcpy( path, pathWitParams.c_str(), pathWitParams.size() );
385 URL::ParamsMap::const_iterator it;
386 for( it = cgi2.begin(); it != cgi2.end(); ++it )
388 if( replace || cgi1.find( it->first ) == cgi1.end() )
389 cgi1[it->first] = it->second;
392 std::string &v = cgi1[it->first];
408 std::vector<char> &avec )
421 static const int name_overhead = 3;
423 static const int value_overhead = 4;
425 size_t nlen = 0, vlen = 0;
426 for(
auto itr = attrs.begin(); itr != attrs.end(); ++itr )
428 nlen += std::get<xattr_name>( *itr ).size() + name_overhead;
429 vlen += std::get<xattr_value>( *itr ).size() + value_overhead;
441 avec.resize( nlen + vlen, 0 );
442 char *nvec = avec.data(), *vvec = avec.data() + nlen;
444 for(
auto itr = attrs.begin(); itr != attrs.end(); ++itr )
446 const std::string &name = std::get<xattr_name>( *itr );
448 const std::string &value = std::get<xattr_value>( *itr );
459 std::vector<char> &nvec )
472 static const int name_overhead = 3;
475 for(
auto itr = attrs.begin(); itr != attrs.end(); ++itr )
476 nlen += itr->size() + name_overhead;
484 nvec.resize( nlen, 0 );
485 char *nptr = nvec.data();
487 for(
auto itr = attrs.begin(); itr != attrs.end(); ++itr )
static const int kXR_ckpXeq
struct ClientRequestHdr header
struct ClientChkPointRequest chkpoint
void ReAllocate(uint32_t size)
Reallocate the buffer to a new location of a given size.
const char * GetBuffer(uint32_t offset=0) const
Get the message buffer.
static Log * GetLog()
Get default log.
static PostMaster * GetPostMaster()
Get default post master.
static Env * GetEnv()
Get default client environment.
bool GetInt(const std::string &key, int &value)
void Error(uint64_t topic, const char *format,...)
Report an error.
void Dump(uint64_t topic, const char *format,...)
Print a dump message.
static void MergeCGI(URL::ParamsMap &cgi1, const URL::ParamsMap &cgi2, bool replace)
Merge cgi2 into cgi1.
static Status CreateXAttrVec(const std::vector< xattr_t > &attrs, std::vector< char > &avec)
Create xattr vector.
static void ProcessSendParams(MessageSendParams &sendParams)
Process sending params.
static void RewriteCGIAndPath(Message *msg, const URL::ParamsMap &newCgi, bool replace, const std::string &newPath, std::string *opathp=nullptr)
Append cgi to the one already present in the message.
static Status RedirectMessage(const URL &url, Message *msg, ResponseHandler *handler, MessageSendParams &sendParams, LocalFileHandler *lFileHandler)
Redirect message.
static XRootDStatus SendMessage(const URL &url, Message *msg, ResponseHandler *handler, MessageSendParams &sendParams, LocalFileHandler *lFileHandler)
Send message.
The message representation used throughout the system.
const std::string & GetObfuscatedDescription() const
Get the description of the message with authz parameter obfuscated.
A hub for dispatching and receiving messages.
XRootDStatus Send(const URL &url, Message *msg, MsgHandler *handler, bool stateful, time_t expires)
Status Redirect(const URL &url, Message *msg, MsgHandler *handler)
Singleton access to URL to virtual redirector mapping.
static RedirectorRegistry & Instance()
Returns reference to the single instance.
XRootDStatus Register(const URL &url)
Creates a new virtual redirector and registers it (async).
Handle an async response.
static SIDMgrPool & Instance()
const std::string & GetPath() const
Get the path.
std::string GetHostId() const
Get the host part of the URL (user:password@host:port).
std::map< std::string, std::string > ParamsMap
void SetParams(const std::string ¶ms)
Set params.
std::string GetPathWithFilteredParams() const
Get the path with params, filteres out 'xrdcl.'.
void SetPath(const std::string &path)
Set the path.
const ParamsMap & GetParams() const
Get the URL params.
bool IsValid() const
Is the url valid.
Handle/Process/Forward XRootD messages.
void SetRedirectCounter(uint16_t redirectCounter)
Set the redirect counter.
void SetFollowMetalink(bool followMetalink)
void SetChunkList(ChunkList *chunkList)
Set the chunk list.
void SetHostList(HostList *hostList)
Set host list.
void SetCrc32cDigests(std::vector< uint32_t > &&crc32cDigests)
void SetLoadBalancer(const HostInfo &loadBalancer)
Set the load balancer.
void SetStateful(bool stateful)
void SetOksofarAsAnswer(bool oksofarAsAnswer)
void SetKernelBuffer(XrdSys::KernelBuffer *kbuff)
Set the kernel buffer.
void SetExpiration(time_t expiration)
Set a timestamp after which we give up.
void SetRedirectAsAnswer(bool redirectAsAnswer)
static void SetDescription(Message *msg)
Get the description of a message.
static XRootDStatus UnMarshallRequest(Message *msg)
static XRootDStatus MarshallRequest(Message *msg)
Marshal the outgoing message.
const int DefaultPreserveLocateTried
const int DefaultRedirectLimit
const uint16_t errUninitialized
const uint16_t stError
An error occurred that could potentially be retried.
std::vector< HostInfo > HostList
const uint16_t errInvalidArgs
const int DefaultRequestTimeout
static char * VVecInsert(const char *value, char *buffer)
static char * NVecInsert(const char *name, char *buffer)
std::vector< uint32_t > crc32cDigests
XrdSys::KernelBuffer * kbuff
Procedure execution status.
bool IsOK() const
We're fine.
std::string ToString() const
Create a string representation.