1919import io .minio .messages .LegalHold ;
2020import io .minio .messages .RetentionMode ;
2121import java .time .ZonedDateTime ;
22- import java .util .ArrayList ;
22+ import java .util .HashMap ;
2323import java .util .List ;
2424import java .util .Locale ;
2525import java .util .Map ;
@@ -34,6 +34,7 @@ public class HeadObjectResponse extends GenericResponse {
3434 private LegalHold lockLegalHold ;
3535 private boolean deleteMarker ;
3636 private Http .Headers userMetadata ;
37+ private Map <Checksum .Algorithm , String > checksums ;
3738 private Checksum .Type checksumType ;
3839
3940 public HeadObjectResponse (okhttp3 .Headers headers , String bucket , String region , String object ) {
@@ -72,6 +73,19 @@ public HeadObjectResponse(okhttp3.Headers headers, String bucket, String region,
7273
7374 value = headers .get ("x-amz-checksum-type" );
7475 this .checksumType = value == null ? null : Checksum .Type .valueOf (value );
76+
77+ Map <Checksum .Algorithm , String > checksums = new HashMap <>();
78+ value = headers .get ("x-amz-checksum-crc32" );
79+ if (value != null && !value .isEmpty ()) checksums .put (Checksum .Algorithm .CRC32 , value );
80+ value = headers .get ("x-amz-checksum-crc32c" );
81+ if (value != null && !value .isEmpty ()) checksums .put (Checksum .Algorithm .CRC32C , value );
82+ value = headers .get ("x-amz-checksum-crc64nvme" );
83+ if (value != null && !value .isEmpty ()) checksums .put (Checksum .Algorithm .CRC64NVME , value );
84+ value = headers .get ("x-amz-checksum-sha1" );
85+ if (value != null && !value .isEmpty ()) checksums .put (Checksum .Algorithm .SHA1 , value );
86+ value = headers .get ("x-amz-checksum-sha256" );
87+ if (value != null && !value .isEmpty ()) checksums .put (Checksum .Algorithm .SHA256 , value );
88+ if (checksums .size () != 0 ) this .checksums = checksums ;
7589 }
7690
7791 public String etag () {
@@ -118,32 +132,13 @@ public Checksum.Type checksumType() {
118132 return checksumType ;
119133 }
120134
121- public List <Checksum .Algorithm > algorithms () {
122- okhttp3 .Headers headers = headers ();
123- List <Checksum .Algorithm > algorithms = new ArrayList <>();
124- String value ;
125-
126- value = headers .get ("x-amz-checksum-crc32" );
127- if (value != null && !value .isEmpty ()) algorithms .add (Checksum .Algorithm .CRC32 );
128-
129- value = headers .get ("x-amz-checksum-crc32c" );
130- if (value != null && !value .isEmpty ()) algorithms .add (Checksum .Algorithm .CRC32C );
131-
132- value = headers .get ("x-amz-checksum-crc64nvme" );
133- if (value != null && !value .isEmpty ()) algorithms .add (Checksum .Algorithm .CRC64NVME );
134-
135- value = headers .get ("x-amz-checksum-sha1" );
136- if (value != null && !value .isEmpty ()) algorithms .add (Checksum .Algorithm .SHA1 );
137-
138- value = headers .get ("x-amz-checksum-sha256" );
139- if (value != null && !value .isEmpty ()) algorithms .add (Checksum .Algorithm .SHA256 );
140-
141- return algorithms .size () == 0 ? null : algorithms ;
135+ public Map <Checksum .Algorithm , String > checksums () {
136+ return checksums ;
142137 }
143138
144139 @ Override
145140 public String toString () {
146- return "ObjectHead {"
141+ return "HeadObjectResponse {"
147142 + "bucket="
148143 + bucket ()
149144 + ", object="
0 commit comments