From c47b0151bba01a06753bcfbdcdcea80db1c88ed2 Mon Sep 17 00:00:00 2001 From: Elvin Sindrilaru Date: Wed, 22 Jan 2020 10:21:28 +0100 Subject: [PATCH 1/2] [XrdTpc] Properly forward existing opaque info to the OFS layer --- src/XrdCeph | 2 +- src/XrdClHttp | 2 +- src/XrdTpc/XrdTpcTPC.cc | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/XrdCeph b/src/XrdCeph index a6a9bd64778..34ea80a4d6e 160000 --- a/src/XrdCeph +++ b/src/XrdCeph @@ -1 +1 @@ -Subproject commit a6a9bd64778e2f0b2e153163550bf40560029007 +Subproject commit 34ea80a4d6e2968cfd4ea3051917b29208ae179e diff --git a/src/XrdClHttp b/src/XrdClHttp index 705c5441e7a..f37b9a3da4e 160000 --- a/src/XrdClHttp +++ b/src/XrdClHttp @@ -1 +1 @@ -Subproject commit 705c5441e7a140a1a97dd2035bc441b0384a183c +Subproject commit f37b9a3da4e2d0d973f81ccd23ed44ead65968f8 diff --git a/src/XrdTpc/XrdTpcTPC.cc b/src/XrdTpc/XrdTpcTPC.cc index 988c9b8ebbf..0576176bf61 100644 --- a/src/XrdTpc/XrdTpcTPC.cc +++ b/src/XrdTpc/XrdTpcTPC.cc @@ -208,8 +208,20 @@ int TPCHandler::OpenWaitStall(XrdSfsFile &fh, const std::string &resource, while (1) { int orig_ucap = fh.error.getUCap(); fh.error.setUCap(orig_ucap | XrdOucEI::uIPv64); - open_result = fh.open(resource.c_str(), mode, openMode, &sec, - authz.empty() ? NULL: authz.c_str()); + std::string opaque; + size_t pos = resource.find('?'); + // Extract the path and opaque info from the resource + std::string path = resource.substr(0, pos); + + if (pos != std::string::npos) { + opaque = resource.substr(pos + 1); + } + + // Append the authz information + opaque += (opaque.empty() ? "" : "&"); + opaque += authz; + open_result = fh.open(path.c_str(), mode, openMode, &sec, opaque.c_str()); + if ((open_result == SFS_STALL) || (open_result == SFS_STARTED)) { int secs_to_stall = fh.error.getErrInfo(); if (open_result == SFS_STARTED) {secs_to_stall = secs_to_stall/2 + 5;} From 47f09a527fc7a96220e403d47ea8af120f6fbd60 Mon Sep 17 00:00:00 2001 From: Elvin Sindrilaru Date: Wed, 22 Jan 2020 11:42:52 +0100 Subject: [PATCH 2/2] [XrdTpc] Properly format redirection URL when OFS layer returns also opaque information --- src/XrdTpc/XrdTpcTPC.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/XrdTpc/XrdTpcTPC.cc b/src/XrdTpc/XrdTpcTPC.cc index 0576176bf61..184af3bf2e5 100644 --- a/src/XrdTpc/XrdTpcTPC.cc +++ b/src/XrdTpc/XrdTpcTPC.cc @@ -190,13 +190,29 @@ std::string TPCHandler::GetAuthz(XrdHttpExtReq &req) { int TPCHandler::RedirectTransfer(const std::string &redirect_resource, XrdHttpExtReq &req, XrdOucErrInfo &error) { int port; - const char *host = error.getErrText(port); - if ((host == NULL) || (*host == '\0') || (port == 0)) { + const char *ptr = error.getErrText(port); + if ((ptr == NULL) || (*ptr == '\0') || (port == 0)) { char msg[] = "Internal error: redirect without hostname"; return req.SendSimpleResp(500, NULL, NULL, msg, 0); } + + // Construct redirection URL taking into consideration any opaque info + std::string rdr_info = ptr; + std::string host, opaque; + size_t pos = rdr_info.find('?'); + host = rdr_info.substr(0, pos); + + if (pos != std::string::npos) { + opaque = rdr_info.substr(pos + 1); + } + std::stringstream ss; ss << "Location: http" << (m_desthttps ? "s" : "") << "://" << host << ":" << port << "/" << redirect_resource; + + if (!opaque.empty()) { + ss << "?" << opaque; + } + return req.SendSimpleResp(307, NULL, const_cast(ss.str().c_str()), NULL, 0); }