-
Notifications
You must be signed in to change notification settings - Fork 149
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] A GET with 'Want-Digest' header request issued on a non-existing file will return a 404 error instead of 500 #2019
Conversation
2a480e1
to
0d83adc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I said, I'm OK with this though I do have a question that may or may not lead to another change. So, if @amadio is OK with it so am I.
src/XrdHttp/XrdHttpReq.cc
Outdated
// 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with the way it is but you could be a bit more discerning here. For instance, if the error is kXR_Unsupported then the status code should really be 501 with the text as returned by the server. Which leads to the question why override the server supplied error text with a generic one? Is the original error message lost somewhere? One would expect that the server's error message will better explain how to correct the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overriding is what used to be done, so I understand @ccaffy's choice. However, I agree that your suggestion is an improvement. I suppose we could have something like
switch(xrderrcode) {
case kXR_NotFound:
break; // reuse error code and message already set
case kXR_Unsupported:
httpStatusCode = 501;
break;
default:
httpStatusCode = 500;
httpStatusText = "Underlying filesystem failed to calculate checksum.";
}
prot->SendSimpleResp(httpStatusCode, NULL, NULL, httpStatusText.c_str(), httpStatusText.length(), false);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this improvement. Will apply it now ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uhmmmmm wait please, IMO there may be another corner case, let's talk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, yes, but the question remains why isn't the server's error text
promoted to the repsonse. Should that not be the actual explanation as
opposed to substituting a generic response?
…On Tue, 30 May 2023, Guilherme Amadio wrote:
@amadio commented on this pull request.
> @@ -1798,7 +1798,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) {
Overriding is what used to be done, so I understand @ccaffy's choice. However, I agree that your suggestion is an improvement. I suppose we could have something like
```cpp
switch(xrderrcode) {
case kXR_NotFound:
break; // reuse error code and message already set
case kXR_Unsupported:
httpStatusCode = 501;
break;
default:
httpStatusCode = 500;
httpStatusText = "Underlying filesystem failed to calculate checksum.";
}
prot->SendSimpleResp(httpStatusCode, NULL, NULL, httpStatusText.c_str(), httpStatusText.length(), false);
```
--
Reply to this email directly or view it on GitHub:
#2019 (comment)
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
########################################################################
Use REPLY-ALL to reply to list
To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1
|
It was just that it was done like that. But I agree, let's then just use the server error text that is set by the XRootD layer, it will simplify the code! |
Excellent!
…On Wed, 31 May 2023, ccaffy wrote:
It was just that it was done like that. But I agree, let's then just use the server error text that is set by the XRootD layer, it will simplify the code!
--
Reply to this email directly or view it on GitHub:
#2019 (comment)
You are receiving this because your review was requested.
Message ID: ***@***.***>
|
aa038eb
to
5286c00
Compare
@ccaffy Very nice, but could you squash the two commits into a single one? Thanks! |
…sting file will return a 404 error instead of 500
5286c00
to
849d740
Compare
Done :) |
Fixes #2018.