mirror of
https://github.com/apache/jclouds.git
synced 2025-02-06 01:59:19 +00:00
Tolerate missing or extra quotes in ETags
References andrewgaul/s3proxy#77.
This commit is contained in:
parent
8d87bfc61b
commit
25f4807df8
@ -630,11 +630,11 @@ public final class LocalBlobStore implements BlobStore {
|
||||
|
||||
if (options != null) {
|
||||
if (options.getIfMatch() != null) {
|
||||
if (!blob.getMetadata().getETag().equals(options.getIfMatch()))
|
||||
if (!maybeQuoteETag(blob.getMetadata().getETag()).equals(options.getIfMatch()))
|
||||
throw returnResponseException(412);
|
||||
}
|
||||
if (options.getIfNoneMatch() != null) {
|
||||
if (blob.getMetadata().getETag().equals(options.getIfNoneMatch()))
|
||||
if (maybeQuoteETag(blob.getMetadata().getETag()).equals(options.getIfNoneMatch()))
|
||||
throw returnResponseException(304);
|
||||
}
|
||||
if (options.getIfModifiedSince() != null) {
|
||||
@ -857,4 +857,11 @@ public final class LocalBlobStore implements BlobStore {
|
||||
public int getMaximumNumberOfParts() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
private static String maybeQuoteETag(String eTag) {
|
||||
if (!eTag.startsWith("\"") && !eTag.endsWith("\"")) {
|
||||
eTag = "\"" + eTag + "\"";
|
||||
}
|
||||
return eTag;
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public class GetOptions extends BaseHttpRequestOptions {
|
||||
public GetOptions ifETagMatches(String eTag) {
|
||||
checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifETagMatches()");
|
||||
checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifETagMatches()");
|
||||
this.headers.put(IF_MATCH, String.format("\"%1$s\"", checkNotNull(eTag, "eTag")));
|
||||
this.headers.put(IF_MATCH, maybeQuoteETag(checkNotNull(eTag, "eTag")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ public class GetOptions extends BaseHttpRequestOptions {
|
||||
public GetOptions ifETagDoesntMatch(String eTag) {
|
||||
checkArgument(getIfMatch() == null, "ifETagMatches() is not compatible with ifETagDoesntMatch()");
|
||||
checkArgument(getIfUnmodifiedSince() == null, "ifUnmodifiedSince() is not compatible with ifETagDoesntMatch()");
|
||||
this.headers.put(IF_NONE_MATCH, String.format("\"%1$s\"", checkNotNull(eTag, "ifETagDoesntMatch")));
|
||||
this.headers.put(IF_NONE_MATCH, maybeQuoteETag(checkNotNull(eTag, "ifETagDoesntMatch")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -299,4 +299,10 @@ public class GetOptions extends BaseHttpRequestOptions {
|
||||
+ ", payload=" + payload + ", pathSuffix=" + pathSuffix + ", ranges=" + ranges + "]";
|
||||
}
|
||||
|
||||
private static String maybeQuoteETag(String eTag) {
|
||||
if (!eTag.startsWith("\"") && !eTag.endsWith("\"")) {
|
||||
eTag = "\"" + eTag + "\"";
|
||||
}
|
||||
return eTag;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user