Skip to content

Commit

Permalink
[XrdHttp] A GET with 'Want-Digest' header request issued on a non-exi…
Browse files Browse the repository at this point in the history
…sting file will return a 404 error instead of 500
  • Loading branch information
ccaffy committed May 31, 2023
1 parent 946cb96 commit e100cda
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/XrdHttp/XrdHttpReq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,16 @@ XrdHttpReq::PostProcessChecksum(std::string &digest_header) {
if (convert_to_base64) {free(digest_value);}
return 0;
} else {
prot->SendSimpleResp(500, NULL, NULL, "Underlying filesystem failed to calculate checksum.", 0, false);
// This is a result of the "Ugly" hack put in place to prevent a failing stat() on a
// non-manager server to fail a transfer.
// In the case a user issues a GET with a 'Want-Digest' header on a non-existing file, the non-failing
// stat() will result in a failed checksum query giving a 500 error back to the user.
// Here we just return a 404 instead. httpStatusCode and httpStatusText contain the right reason why the request failed.
if(xrderrcode != kXR_NotFound) {
httpStatusCode = 500;
httpStatusText = "Underlying filesystem failed to calculate checksum.";
}
prot->SendSimpleResp(httpStatusCode, NULL, NULL, httpStatusText.c_str(), httpStatusText.length(), false);
return -1;
}
}
Expand Down

0 comments on commit e100cda

Please sign in to comment.