API/CopyObject: Refactor the code and handle if-modified-since as well. (#2183)

This completes the S3 spec behavior for CopyObject API as reported
by `s3verify`.
This commit is contained in:
Harshavardhana
2016-07-11 19:24:34 -07:00
committed by GitHub
parent bef72f26db
commit e9647b5f12
2 changed files with 98 additions and 122 deletions
+4 -17
View File
@@ -130,7 +130,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
}
// Validate pre-conditions if any.
if checkPreconditions(r, w, objInfo) {
if checkPreconditions(w, r, objInfo) {
return
}
@@ -217,7 +217,7 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re
}
// Validate pre-conditions if any.
if checkPreconditions(r, w, objInfo) {
if checkPreconditions(w, r, objInfo) {
return
}
@@ -295,21 +295,8 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
return
}
// Verify before writing.
// Verify x-amz-copy-source-if-modified-since and
// x-amz-copy-source-if-unmodified-since.
lastModified := objInfo.ModTime
if checkCopySourceLastModified(w, r, lastModified) {
return
}
if objInfo.MD5Sum != "" {
w.Header().Set("ETag", "\""+objInfo.MD5Sum+"\"")
}
// Verify x-amz-copy-source-if-match and x-amz-copy-source-if-none-match.
if checkCopySourceETag(w, r) {
// Verify before x-amz-copy-source preconditions before continuing with CopyObject.
if checkCopyObjectPreconditions(w, r, objInfo) {
return
}