Translate KeyTooLongError to ENAMETOOLONG (#1602)

AWS does not support keys longer than 1024 characters.  Add special
handling for HeadObject which does not have a response body.
Found via pjdfstests.  References #1589.
This commit is contained in:
Andrew Gaul 2021-03-28 13:17:41 +09:00 committed by GitHub
parent f6fbd75320
commit 9645d57c05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2297,6 +2297,9 @@ int S3fsCurl::RequestPerform(bool dontAddAuthHeaders /*=false*/)
if(value == "EntityTooLarge"){
result = -EFBIG;
break;
}else if(value == "KeyTooLongError"){
result = -ENAMETOOLONG;
break;
}
}
}
@ -2312,7 +2315,11 @@ int S3fsCurl::RequestPerform(bool dontAddAuthHeaders /*=false*/)
case 400:
if(op == "HEAD"){
S3FS_PRN_ERR("HEAD HTTP response code %ld, returning EPERM. Body Text: %s", responseCode, bodydata.str());
if(path.size() > 1024){
S3FS_PRN_ERR("HEAD HTTP response code %ld with path longer than 1024, returning ENAMETOOLONG.", responseCode);
return -ENAMETOOLONG;
}
S3FS_PRN_ERR("HEAD HTTP response code %ld, returning EPERM.", responseCode);
result = -EPERM;
}else{
S3FS_PRN_ERR("HTTP response code %ld, returning EIO. Body Text: %s", responseCode, bodydata.str());