S3 API: conditional read and write (#7154)

* conditional put

* more tests

* check all conditions

* address comments

* conditional multipart complete

* conditional reads

Read Operations (GET, HEAD):
If-None-Match / If-Modified-Since failures → 304 Not Modified 
If-Match / If-Unmodified-Since failures → 412 Precondition Failed 
Write Operations (PUT, CompleteMultipartUpload):
All conditional failures → 412 Precondition Failed 
Copy Operations (CopyObject):
Copy-source conditionals → 412 Precondition Failed (already implemented) 

* test actual code

* Interface-Based Testing

* cleanup

* Testing Interface

* Update s3api_object_handlers_put.go

* refactor
This commit is contained in:
Chris Lu
2025-08-22 16:58:09 -07:00
committed by GitHub
parent 50530e2553
commit 34773c8e13
6 changed files with 1155 additions and 0 deletions

View File

@@ -246,6 +246,13 @@ func (s3a *S3ApiServer) GetObjectHandler(w http.ResponseWriter, r *http.Request)
return // Directory object request was handled
}
// Check conditional headers for read operations
if errCode := s3a.checkConditionalHeadersForReads(r, bucket, object); errCode != s3err.ErrNone {
glog.V(3).Infof("GetObjectHandler: Conditional header check failed for %s/%s with error %v", bucket, object, errCode)
s3err.WriteErrorResponse(w, r, errCode)
return
}
// Check for specific version ID in query parameters
versionId := r.URL.Query().Get("versionId")
@@ -378,6 +385,13 @@ func (s3a *S3ApiServer) HeadObjectHandler(w http.ResponseWriter, r *http.Request
return // Directory object request was handled
}
// Check conditional headers for read operations
if errCode := s3a.checkConditionalHeadersForReads(r, bucket, object); errCode != s3err.ErrNone {
glog.V(3).Infof("HeadObjectHandler: Conditional header check failed for %s/%s with error %v", bucket, object, errCode)
s3err.WriteErrorResponse(w, r, errCode)
return
}
// Check for specific version ID in query parameters
versionId := r.URL.Query().Get("versionId")