diff --git a/src/XProtocol/XProtocol.hh b/src/XProtocol/XProtocol.hh index eb9af2c7953..561161d9913 100644 --- a/src/XProtocol/XProtocol.hh +++ b/src/XProtocol/XProtocol.hh @@ -1370,7 +1370,12 @@ static int mapError(int rc) case ENOTBLK: return kXR_NotFile; case ENOTSUP: return kXR_Unsupported; case EISDIR: return kXR_isDirectory; - case EEXIST: return kXR_ItExists; + case ENOTEMPTY: [[fallthrough]]; + // In the case one tries to delete a non-empty directory + // we have decided that until the next major release + // the kXR_ItExists flag will be returned + case EEXIST: + return kXR_ItExists; case EBADRQC: return kXR_InvalidRequest; case ETXTBSY: return kXR_inProgress; case ENODEV: return kXR_FSError; diff --git a/src/XrdHttp/XrdHttpReq.cc b/src/XrdHttp/XrdHttpReq.cc index 69eb816fc0c..732ca2e4254 100644 --- a/src/XrdHttp/XrdHttpReq.cc +++ b/src/XrdHttp/XrdHttpReq.cc @@ -926,7 +926,14 @@ void XrdHttpReq::mapXrdErrorToHttpStatus() { httpStatusCode = 409; httpStatusText = "Resource is a directory"; break; case kXR_ItExists: - httpStatusCode = 409; httpStatusText = "File already exists"; + if(request != ReqType::rtDELETE) { + httpStatusCode = 409; httpStatusText = "File already exists"; + } else { + // In the case the XRootD layer returns a kXR_ItExists after a deletion + // was submitted, we return a 405 status code with the error message set by + // the XRootD layer + httpStatusCode = 405; + } break; case kXR_InvalidRequest: httpStatusCode = 405; httpStatusText = "Method is not allowed";