1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-08 08:26:10 +00:00

Proxy settings read from System and loaded in host configuration

This commit is contained in:
David A. Velasco 2014-09-22 12:23:30 +02:00
parent ff0de72ea5
commit c29631b8bf

View File

@ -30,6 +30,7 @@ import java.io.InputStream;
import org.apache.commons.httpclient.Cookie; import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpConnectionManager; import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpException;
@ -92,10 +93,32 @@ public class OwnCloudClient extends HttpClient {
PARAM_SINGLE_COOKIE_HEADER, // to avoid problems with some web servers PARAM_SINGLE_COOKIE_HEADER, // to avoid problems with some web servers
PARAM_SINGLE_COOKIE_HEADER_VALUE); PARAM_SINGLE_COOKIE_HEADER_VALUE);
applyProxySettings();
clearCredentials(); clearCredentials();
} }
private void applyProxySettings() {
String proxyHost = System.getProperty("http.proxyHost");
String proxyPortSt = System.getProperty("http.proxyPort");
int proxyPort = 0;
try {
if (proxyPortSt != null && proxyPortSt.length() > 0) {
proxyPort = Integer.parseInt(proxyPortSt);
}
} catch (Exception e) {
// nothing to do here
}
if (proxyHost != null && proxyHost.length() > 0) {
HostConfiguration hostCfg = getHostConfiguration();
hostCfg.setProxy(proxyHost, proxyPort);
Log_OC.d(TAG, "Proxy settings: " + proxyHost + ":" + proxyPort);
}
}
public void setCredentials(OwnCloudCredentials credentials) { public void setCredentials(OwnCloudCredentials credentials) {
if (credentials != null) { if (credentials != null) {
mCredentials = credentials; mCredentials = credentials;