Bug 1209496 - DownloadContentService: Add proxy support. r=sebastian

MozReview-Commit-ID: 8FZpWG9cTVA

--HG--
extra : rebase_source : 2c28b3e8f65c442becee9e46ffcc01f7ada43db7
This commit is contained in:
Krishna 2016-05-09 19:26:57 +02:00
parent 821ec6b348
commit e9e6a3972d

View File

@ -16,6 +16,7 @@ import org.mozilla.gecko.dlc.catalog.DownloadContentCatalog;
import org.mozilla.gecko.sync.Utils;
import org.mozilla.gecko.util.HardwareUtils;
import org.mozilla.gecko.util.IOUtils;
import org.mozilla.gecko.util.ProxySelector;
import java.io.BufferedInputStream;
import java.io.File;
@ -24,7 +25,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
public abstract class BaseAction {
private static final String LOGTAG = "GeckoDLCBaseAction";
@ -145,11 +147,10 @@ public abstract class BaseAction {
protected HttpURLConnection buildHttpURLConnection(String url)
throws UnrecoverableDownloadContentException, IOException {
// TODO: Implement proxy support (Bug 1209496)
try {
System.setProperty("http.keepAlive", "true");
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
HttpURLConnection connection = (HttpURLConnection) ProxySelector.openConnectionWithProxy(new URI(url));
connection.setRequestProperty("User-Agent", HardwareUtils.isTablet() ?
AppConstants.USER_AGENT_FENNEC_TABLET :
AppConstants.USER_AGENT_FENNEC_MOBILE);
@ -158,6 +159,8 @@ public abstract class BaseAction {
return connection;
} catch (MalformedURLException e) {
throw new UnrecoverableDownloadContentException(e);
} catch (URISyntaxException e) {
throw new UnrecoverableDownloadContentException(e);
}
}
}