Make CORS handling optional

If corsRules is null, construct the default rules.  Also add HEAD method for CORS

Co-authored-by: Shannon Noe <shannon.noe@drwholdings.com>
pull/361/head
snoe925 2021-03-06 20:30:26 -06:00 zatwierdzone przez GitHub
rodzic 48d10653c5
commit 4a6a3f2f4a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 9 dodań i 4 usunięć

Wyświetl plik

@ -33,9 +33,9 @@ import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final class CrossOriginResourceSharing {
final class CrossOriginResourceSharing {
protected static final Collection<String> SUPPORTED_METHODS =
ImmutableList.of("GET", "PUT", "POST");
ImmutableList.of("GET", "HEAD", "PUT", "POST");
private static final String HEADER_VALUE_SEPARATOR = ", ";
private static final String ALLOW_ANY_ORIGIN = "*";

Wyświetl plik

@ -220,8 +220,14 @@ public class S3ProxyHandler {
AuthenticationType authenticationType, final String identity,
final String credential, @Nullable String virtualHost,
long maxSinglePartObjectSize, long v4MaxNonChunkedRequestSize,
boolean ignoreUnknownHeaders, CrossOriginResourceSharing corsRules,
boolean ignoreUnknownHeaders,
@Nullable CrossOriginResourceSharing corsRules,
final String servicePath, int maximumTimeSkew) {
if (corsRules != null) {
this.corsRules = corsRules;
} else {
this.corsRules = new CrossOriginResourceSharing();
}
if (authenticationType != AuthenticationType.NONE) {
anonymousIdentity = false;
blobStoreLocator = new BlobStoreLocator() {
@ -252,7 +258,6 @@ public class S3ProxyHandler {
this.maxSinglePartObjectSize = maxSinglePartObjectSize;
this.v4MaxNonChunkedRequestSize = v4MaxNonChunkedRequestSize;
this.ignoreUnknownHeaders = ignoreUnknownHeaders;
this.corsRules = corsRules;
this.defaultBlobStore = blobStore;
xmlOutputFactory.setProperty("javax.xml.stream.isRepairingNamespaces",
Boolean.FALSE);