[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:
Yuval Kashtan 2017-11-30 10:22:57 +02:00 committed by Ignasi Barrera
parent 624367dfbf
commit 17cef5652f
1 changed files with 2 additions and 2 deletions

View File

@ -56,7 +56,7 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
@Named(PROPERTY_USER_METADATA_PREFIX) String metadataPrefix) {
this.metadataFactory = checkNotNull(metadataFactory, "metadataFactory");
this.dateParser = checkNotNull(dateParser, "dateParser");
this.metadataPrefix = checkNotNull(metadataPrefix, "metadataPrefix");
this.metadataPrefix = checkNotNull(metadataPrefix, "metadataPrefix").toLowerCase();
}
public MutableBlobMetadata apply(HttpResponse from) {
@ -77,7 +77,7 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function<HttpRespo
@VisibleForTesting
void addUserMetadataTo(HttpResponse from, MutableBlobMetadata metadata) {
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(),
header.getValue());
}