Skip to content

Commit f562ebc

Browse files
vadmesteharshavardhana
authored andcommitted
api: Set correct (un)modified condition header (#547)
This PR sets the correct date time format for headers x-amz-copy-if-modified-since and x-amz-copy-source-if-unmodified-since. In consequence, modified/unmodified copy preconditions will just work.
1 parent d0ddb4c commit f562ebc

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

api/src/main/java/io/minio/DateFormat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class DateFormat {
3838
DateTimeFormat.forPattern("yyyyMMdd").withZoneUTC().withLocale(Locale.US);
3939

4040
public static final DateTimeFormatter HTTP_HEADER_DATE_FORMAT =
41-
DateTimeFormat.forPattern("EEE',' dd MMM yyyy HH':'mm':'ss zzz").withZoneUTC().withLocale(Locale.US);
41+
DateTimeFormat.forPattern("EEE',' dd MMM yyyy HH':'mm':'ss 'GMT'").withZoneUTC().withLocale(Locale.US);
4242

4343
private DateFormat() {}
4444
}

functional/FunctionalTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,11 +1055,13 @@ public static void copyObject_test7() throws Exception {
10551055
client.copyObject(bucketName, filename, destBucketName, copyConditions);
10561056
} catch (ErrorResponseException e) {
10571057
// File should not be copied as object was modified after date set in copyConditions.
1058-
ignore();
1058+
if (!e.errorResponse().code().equals("PreconditionFailed")) {
1059+
throw e;
1060+
}
10591061
}
10601062

10611063
client.removeObject(bucketName, filename);
1062-
client.removeObject(destBucketName, filename);
1064+
// Destination bucket is expected to be empty, otherwise it will trigger an exception.
10631065
client.removeBucket(destBucketName);
10641066
}
10651067

0 commit comments

Comments
 (0)