[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser/tor-browser-68.1.0esr-9.0-1] Bug 27016 - Create proxy connection during image download



commit 9ccc623f7ecb6e1031a2e43dad0f71ea5c6d8119
Author: Matthew Finkel <Matthew.Finkel@xxxxxxxxx>
Date:   Thu Aug 2 21:49:05 2018 +0000

    Bug 27016 - Create proxy connection during image download
    
    Picasso, the image retrieval library used by Fennec, ignores the network
    proxy configuration. We override the openConnection() method and create
    the connection using the configured proxy.
---
 .../java/org/mozilla/gecko/home/ImageLoader.java   | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/mobile/android/base/java/org/mozilla/gecko/home/ImageLoader.java b/mobile/android/base/java/org/mozilla/gecko/home/ImageLoader.java
index 2bbd82a8df77..cbbe7babbba4 100644
--- a/mobile/android/base/java/org/mozilla/gecko/home/ImageLoader.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/ImageLoader.java
@@ -15,9 +15,14 @@ import com.squareup.picasso.Picasso;
 import com.squareup.picasso.Downloader.Response;
 import com.squareup.picasso.UrlConnectionDownloader;
 
+import org.mozilla.gecko.util.ProxySelector;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.EnumSet;
 import java.util.Set;
 
@@ -84,6 +89,23 @@ public class ImageLoader {
             this.distribution = distribution;
         }
 
+        @Override
+        protected HttpURLConnection openConnection(Uri path) throws IOException {
+            try {
+                // This is annoying, but |path| is an android.net.Uri and
+                // openConnectionWithProxy() accepts a java.net.URI
+                return (HttpURLConnection)ProxySelector.openConnectionWithProxy(
+                        new URI(
+                            path.getScheme(), path.getHost(), path.getPath(),
+                            path.getEncodedFragment()));
+            } catch (URISyntaxException ex) {
+                // And android.net.Uri is more lenient than java.net.URI.
+                // Uri does not catch syntax errors which URI may catch.
+                // We'll re-throw this as an IOException
+                throw new IOException(ex.getMessage());
+            }
+        }
+
         private Density getDensity(float factor) {
             final DisplayMetrics dm = context.getResources().getDisplayMetrics();
             final float densityDpi = dm.densityDpi * factor;



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits