From 640b96f85bdcfd97ae3b353683c11f30a09f0841 Mon Sep 17 00:00:00 2001 From: Agi Sferro Date: Mon, 19 Oct 2020 15:45:17 +0000 Subject: [PATCH] Bug 1671571 - Don't pass null headers in Loader. r=snorp Differential Revision: https://phabricator.services.mozilla.com/D93811 --- .../org/mozilla/geckoview/GeckoSession.java | 55 ++++++++++++++----- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java index e61488b0deb5..9f3e5b375c2d 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java @@ -1765,10 +1765,15 @@ public class GeckoSession { @AnyThread @Deprecated public void loadUri(final @NonNull String uri, final @Nullable Map additionalHeaders) { - load(new Loader() + final Loader loader = new Loader() .uri(uri) - .headerFilter(HEADER_FILTER_UNRESTRICTED_UNSAFE) - .additionalHeaders(additionalHeaders)); + .headerFilter(HEADER_FILTER_UNRESTRICTED_UNSAFE); + + if (additionalHeaders != null) { + loader.additionalHeaders(additionalHeaders); + } + + load(loader); } /** @@ -1819,12 +1824,17 @@ public class GeckoSession { @Deprecated public void loadUri(final @NonNull String uri, final @Nullable String referrer, final @LoadFlags int flags, final @Nullable Map additionalHeaders) { - load(new Loader() + final Loader loader = new Loader() .uri(uri) .headerFilter(HEADER_FILTER_UNRESTRICTED_UNSAFE) .referrer(referrer) - .flags(flags) - .additionalHeaders(additionalHeaders)); + .flags(flags); + + if (additionalHeaders != null) { + loader.additionalHeaders(additionalHeaders); + } + + load(loader); } /** @@ -1863,12 +1873,17 @@ public class GeckoSession { @Deprecated public void loadUri(final @NonNull String uri, final @Nullable GeckoSession referrer, final @LoadFlags int flags, final @Nullable Map additionalHeaders) { - load(new Loader() + final Loader loader = new Loader() .uri(uri) .headerFilter(HEADER_FILTER_UNRESTRICTED_UNSAFE) .referrer(referrer) - .additionalHeaders(additionalHeaders) - .flags(flags)); + .flags(flags); + + if (additionalHeaders != null) { + loader.additionalHeaders(additionalHeaders); + } + + load(loader); } private GeckoResult shouldLoadUri(final NavigationDelegate.LoadRequest request) { @@ -1918,10 +1933,15 @@ public class GeckoSession { @AnyThread @Deprecated public void loadUri(final @NonNull Uri uri, final @Nullable Map additionalHeaders) { - load(new Loader() + final Loader loader = new Loader() .uri(uri) - .headerFilter(HEADER_FILTER_UNRESTRICTED_UNSAFE) - .additionalHeaders(additionalHeaders)); + .headerFilter(HEADER_FILTER_UNRESTRICTED_UNSAFE); + + if (additionalHeaders != null) { + loader.additionalHeaders(additionalHeaders); + } + + load(loader); } /** @@ -1969,12 +1989,17 @@ public class GeckoSession { @Deprecated public void loadUri(final @NonNull Uri uri, final @Nullable Uri referrer, final @LoadFlags int flags, final @Nullable Map additionalHeaders) { - load(new Loader() + final Loader loader = new Loader() .uri(uri) .headerFilter(HEADER_FILTER_UNRESTRICTED_UNSAFE) .referrer(referrer) - .flags(flags) - .additionalHeaders(additionalHeaders)); + .flags(flags); + + if (additionalHeaders != null) { + loader.additionalHeaders(additionalHeaders); + } + + load(loader); } /**