The copy runs to completion before this method returns.
469 log->
Debug(
kLogXrdClHttp,
"XrdClHttp::ThirdPartyCopy src %s dst %s", source.c_str(), dest.c_str());
473 log->
Error(
kLogXrdClHttp,
"Third party copy can only be done between http(s) protocols");
475 "Third party copy can only be done between http(s) protocols");
479 int number_of_streams = 1;
480 time_t init_timeout = 0;
481 time_t tpc_timeout = 0;
482 std::string token_file;
483 bool force_overwrite =
false;
487 mode = properties->
Get<std::string>(
"thirdPartyMode") !=
"push" ? TpcMode::Pull : TpcMode::Push;
488 properties->
Get(
"initTimeout", init_timeout);
489 properties->
Get(
"tpcTimeout", tpc_timeout);
490 token_file = properties->
Get<std::string>(
"thirdPartyTokenFile");
491 properties->
Get(
"force", force_overwrite);
495 if (tpc_timeout == 0)
496 tpc_timeout = timeout;
499 env->GetInt(
"SubStreamsPerChannel", number_of_streams);
505 if (!token_file.empty() && !
ParseTokenFile(token_file, src_hdrs, dst_hdrs))
507 "Failed to parse the token file '" + token_file +
"'");
512 std::any_of(hdrs.begin(), hdrs.end(),
513 [] (
const auto &header) { return header.first ==
"Authorization"s; });
516 if (is_unsecure(src_hdrs, source) || is_unsecure(dst_hdrs, dest))
518 log->
Error(
kLogXrdClHttp,
"Refusing to send an Authorization header over an unencrypted http URL");
520 "Refusing to send an Authorization header over an unencrypted http URL");
526 if (mode == TpcMode::Push && !force_overwrite &&
527 stat_size(*m_queue, dest, dst_hdrs, init_timeout, log,
"destination"))
531 "The destination exists; use --force to replace it");
534 headers.emplace_back(
"X-Number-Of-Streams"s, std::to_string(number_of_streams));
538 dst_hdrs.emplace_back(
"Overwrite"s, force_overwrite ?
"T"s :
"F"s);
540 std::size_t size = 0;
542 if (progress_handler)
544 size =
stat_size(*m_queue, source, src_hdrs, init_timeout, log,
"source").value_or(0);
548 const auto rh = std::make_shared<SyncResponseHandler>();
549 const auto op = std::make_shared<CopyOp>(rh.get(), source, src_hdrs, dest, dst_hdrs, headers,
550 mode, timespec{tpc_timeout, 0}, log,
nullptr);
551 op->SetProgressHandler(progress_handler);
555 m_queue->Produce(std::shared_ptr<CopyOp>(op.get(), [rh, op](
auto){}));
557 catch (
const std::exception &e) {
562 if (!rh->wait(std::chrono::seconds(tpc_timeout)))
565 if (op->IsDone() && !op->IsSentSuccessfully())
568 if (progress_handler && size > 0)
static bool is_http_url(const std::string &url)
std::vector< std::pair< std::string, std::string > > Headers
static Log * GetLog()
Get default log.
static Env * GetEnv()
Get default client environment.
void Error(uint64_t topic, const char *format,...)
Report an error.
void Warning(uint64_t topic, const char *format,...)
Report a warning.
void Debug(uint64_t topic, const char *format,...)
Print a debug message.
virtual void HandleProgress(std::size_t processed, std::size_t total=0)=0
bool Get(const std::string &name, Item &item) const
const std::string & GetProtocol() const
Get the protocol.
static std::optional< std::size_t > stat_size(HandlerQueue &queue, const std::string &url, const CurlCopyOp::Headers &hdrs, time_t timeout, XrdCl::Log *log, const char *what)
bool ParseTokenFile(const std::string &token_file, CurlCopyOp::Headers &src_hdrs, CurlCopyOp::Headers &dst_hdrs)
const uint16_t errErrorResponse
const uint16_t errOperationExpired
const uint16_t errInternal
Internal error.
const uint16_t errPipelineFailed
Pipeline failed and operation couldn't be executed.
const uint16_t errAuthFailed
const uint64_t kLogXrdClHttp