Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XrdHttp: The deletion of a non-empty directory returns a 405 error code instead of 500 #2016

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/XProtocol/XProtocol.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion src/XrdHttp/XrdHttpReq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
abh3 marked this conversation as resolved.
Show resolved Hide resolved
}
break;
case kXR_InvalidRequest:
httpStatusCode = 405; httpStatusText = "Method is not allowed";
Expand Down