From aa1002a0d616b2ce50ce52d2d18e5c223a1365cd Mon Sep 17 00:00:00 2001 From: olly Date: Wed, 19 Oct 2016 05:16:36 -0700 Subject: [PATCH] Rollback "Add REQUIRE_HTTPS flag" *** Reason for rollback *** Flag doesn't enforce what it says it enforces, due to redirects *** Original change description *** Add REQUIRE_HTTPS flag Note that it's not possible for the library to enforce that the flag is adhered to, since it's possible for applications to inject custom implementations of DataSource (there's no requirement they even extend HttpDataSource for network requesting implementations). It's possible for applications to replace pretty much anything in the library, so there's no other place we could put the flag where we could make this guarantee. Hence this is a best-effort that will work when... *** ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=136583459 --- .../ext/cronet/CronetDataSource.java | 3 +- .../ext/okhttp/OkHttpDataSource.java | 3 -- .../android/exoplayer2/ExoPlayerFlags.java | 32 ------------------- .../android/exoplayer2/upstream/DataSpec.java | 7 ---- .../upstream/DefaultHttpDataSource.java | 3 -- 5 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 library/src/main/java/com/google/android/exoplayer2/ExoPlayerFlags.java diff --git a/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java b/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java index e75524c1c9..83f46bd488 100644 --- a/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java +++ b/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java @@ -20,7 +20,6 @@ import android.os.ConditionVariable; import android.text.TextUtils; import android.util.Log; import com.google.android.exoplayer2.C; -import com.google.android.exoplayer2.ExoPlayerFlags; import com.google.android.exoplayer2.upstream.DataSourceException; import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.HttpDataSource; @@ -207,7 +206,7 @@ public class CronetDataSource extends UrlRequest.Callback implements HttpDataSou @Override public long open(DataSpec dataSpec) throws HttpDataSourceException { - Assertions.checkState(!ExoPlayerFlags.REQUIRE_HTTPS || dataSpec.isHttps()); + Assertions.checkNotNull(dataSpec); Assertions.checkState(!opened); operation.close(); diff --git a/extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java b/extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java index 07c607771a..2b6eaa736d 100644 --- a/extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java +++ b/extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java @@ -17,7 +17,6 @@ package com.google.android.exoplayer2.ext.okhttp; import android.net.Uri; import com.google.android.exoplayer2.C; -import com.google.android.exoplayer2.ExoPlayerFlags; import com.google.android.exoplayer2.upstream.DataSourceException; import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.HttpDataSource; @@ -146,8 +145,6 @@ public class OkHttpDataSource implements HttpDataSource { @Override public long open(DataSpec dataSpec) throws HttpDataSourceException { - Assertions.checkState(!ExoPlayerFlags.REQUIRE_HTTPS || dataSpec.isHttps()); - this.dataSpec = dataSpec; this.bytesRead = 0; this.bytesSkipped = 0; diff --git a/library/src/main/java/com/google/android/exoplayer2/ExoPlayerFlags.java b/library/src/main/java/com/google/android/exoplayer2/ExoPlayerFlags.java deleted file mode 100644 index 0af9208d59..0000000000 --- a/library/src/main/java/com/google/android/exoplayer2/ExoPlayerFlags.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.exoplayer2; - -/** - * Global configuration flags. Applications may toggle these flags, but should do so prior to any - * other use of the library. - */ -public final class ExoPlayerFlags { - - /** - * If set, indicates to {@link com.google.android.exoplayer2.upstream.HttpDataSource} - * implementations that they should reject non-HTTPS requests. - */ - public static boolean REQUIRE_HTTPS = false; - - private ExoPlayerFlags() {} - -} diff --git a/library/src/main/java/com/google/android/exoplayer2/upstream/DataSpec.java b/library/src/main/java/com/google/android/exoplayer2/upstream/DataSpec.java index ced276d7eb..d251446976 100644 --- a/library/src/main/java/com/google/android/exoplayer2/upstream/DataSpec.java +++ b/library/src/main/java/com/google/android/exoplayer2/upstream/DataSpec.java @@ -167,13 +167,6 @@ public final class DataSpec { this.flags = flags; } - /** - * Returns whether the instance defines a HTTPS request. - */ - public boolean isHttps() { - return uri != null && "https".equalsIgnoreCase(uri.getScheme()); - } - @Override public String toString() { return "DataSpec[" + uri + ", " + Arrays.toString(postBody) + ", " + absoluteStreamPosition diff --git a/library/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java b/library/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java index 2b3f91c77c..b326c41b18 100644 --- a/library/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java @@ -19,7 +19,6 @@ import android.net.Uri; import android.text.TextUtils; import android.util.Log; import com.google.android.exoplayer2.C; -import com.google.android.exoplayer2.ExoPlayerFlags; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Predicate; import com.google.android.exoplayer2.util.Util; @@ -187,8 +186,6 @@ public class DefaultHttpDataSource implements HttpDataSource { @Override public long open(DataSpec dataSpec) throws HttpDataSourceException { - Assertions.checkState(!ExoPlayerFlags.REQUIRE_HTTPS || dataSpec.isHttps()); - this.dataSpec = dataSpec; this.bytesRead = 0; this.bytesSkipped = 0;