From f0961142316056a74bab42817612f31fa5f3b931 Mon Sep 17 00:00:00 2001 From: Brian Bockelman Date: Sat, 28 Mar 2020 09:30:58 -0500 Subject: [PATCH] Workaround an incorrect error code from the Xrootd bridge. This avoids the issue in #1167, which causes the wrong error code to be given for a known error text. This simply looks for the known error text and corrects the HTTP status code. --- src/XrdHttp/XrdHttpReq.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/XrdHttp/XrdHttpReq.cc b/src/XrdHttp/XrdHttpReq.cc index f86ceb52f73..818aef502fb 100644 --- a/src/XrdHttp/XrdHttpReq.cc +++ b/src/XrdHttp/XrdHttpReq.cc @@ -2621,6 +2621,13 @@ int XrdHttpReq::PostProcessHTTPReq(bool final_) { { if (xrdresp != kXR_ok) { + // Workaround for the cmsd not sending the right error code -- we need to examine the + // text. See GH issue #1167 + if ((httpStatusText == "Unable to create new file; file already exists.\n") || + (httpStatusText == "Unable to create directory; directory already exists.\n")) + { + httpStatusCode = 405; + } prot->SendSimpleResp(httpStatusCode, NULL, NULL, httpStatusText.c_str(), httpStatusText.length(), false); return -1;