mirror of https://github.com/apache/jclouds.git
[JCLOUDS-1363] - Fix case sensitivity of blobstore metadata
HTTP headers are case insensitive by nature (see RFC 2616). When addUserMetadataTo check if this is indeed a user metadata header, it must properly ignore case. The fix make sure that both metadataPrefix and the header key are compared with toLowerCase(). This solves issue with minio metadata read
This commit is contained in:
parent
624367dfbf
commit
17cef5652f
|
@ -56,7 +56,7 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
|
||||||
@Named(PROPERTY_USER_METADATA_PREFIX) String metadataPrefix) {
|
@Named(PROPERTY_USER_METADATA_PREFIX) String metadataPrefix) {
|
||||||
this.metadataFactory = checkNotNull(metadataFactory, "metadataFactory");
|
this.metadataFactory = checkNotNull(metadataFactory, "metadataFactory");
|
||||||
this.dateParser = checkNotNull(dateParser, "dateParser");
|
this.dateParser = checkNotNull(dateParser, "dateParser");
|
||||||
this.metadataPrefix = checkNotNull(metadataPrefix, "metadataPrefix");
|
this.metadataPrefix = checkNotNull(metadataPrefix, "metadataPrefix").toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableBlobMetadata apply(HttpResponse from) {
|
public MutableBlobMetadata apply(HttpResponse from) {
|
||||||
|
@ -77,7 +77,7 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void addUserMetadataTo(HttpResponse from, MutableBlobMetadata metadata) {
|
void addUserMetadataTo(HttpResponse from, MutableBlobMetadata metadata) {
|
||||||
for (Entry<String, String> header : from.getHeaders().entries()) {
|
for (Entry<String, String> header : from.getHeaders().entries()) {
|
||||||
if (header.getKey() != null && header.getKey().startsWith(metadataPrefix))
|
if (header.getKey() != null && header.getKey().toLowerCase().startsWith(metadataPrefix))
|
||||||
metadata.getUserMetadata().put((header.getKey().substring(metadataPrefix.length())).toLowerCase(),
|
metadata.getUserMetadata().put((header.getKey().substring(metadataPrefix.length())).toLowerCase(),
|
||||||
header.getValue());
|
header.getValue());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue