Skip to content

Commit

Permalink
XrdHttp: The deletion of a non-empty directory returns a 405 error co…
Browse files Browse the repository at this point in the history
…de instead of 500

The mapping between errno error codes and XRoot protocol error code has also
been changed. ENOTEMPTY is mapped to kXR_ItExists
  • Loading branch information
ccaffy committed May 30, 2023
1 parent 7f7caa2 commit 7a1295a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/XProtocol/XProtocol.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,10 @@ static int mapError(int rc)
case ETIMEDOUT: return kXR_ReqTimedOut;
case EBADF: return kXR_FileNotOpen;
case ECANCELED: return kXR_Cancelled;
// 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 ENOTEMPTY: return kXR_ItExists;
default: 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;
}
break;
case kXR_InvalidRequest:
httpStatusCode = 405; httpStatusText = "Method is not allowed";
Expand Down

0 comments on commit 7a1295a

Please sign in to comment.