mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 00:16:09 +00:00
Merge pull request #142 from owncloud/crash_invalid_port
Fix crash with invalid TCP port
This commit is contained in:
commit
457d4f3d2f
@ -39,6 +39,7 @@ import org.apache.commons.httpclient.HttpMethodBase;
|
|||||||
import org.apache.commons.httpclient.HttpStatus;
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.HttpVersion;
|
import org.apache.commons.httpclient.HttpVersion;
|
||||||
import org.apache.commons.httpclient.URI;
|
import org.apache.commons.httpclient.URI;
|
||||||
|
import org.apache.commons.httpclient.URIException;
|
||||||
import org.apache.commons.httpclient.cookie.CookiePolicy;
|
import org.apache.commons.httpclient.cookie.CookiePolicy;
|
||||||
import org.apache.commons.httpclient.methods.HeadMethod;
|
import org.apache.commons.httpclient.methods.HeadMethod;
|
||||||
import org.apache.commons.httpclient.params.HttpMethodParams;
|
import org.apache.commons.httpclient.params.HttpMethodParams;
|
||||||
@ -79,7 +80,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
super(connectionMgr);
|
super(connectionMgr);
|
||||||
|
|
||||||
if (baseUri == null) {
|
if (baseUri == null) {
|
||||||
throw new IllegalArgumentException("Parameter 'baseUri' cannot be NULL");
|
throw new IllegalArgumentException("Parameter 'baseUri' cannot be NULL");
|
||||||
}
|
}
|
||||||
mBaseUri = baseUri;
|
mBaseUri = baseUri;
|
||||||
|
|
||||||
@ -89,14 +90,15 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
String userAgent = OwnCloudClientManagerFactory.getUserAgent();
|
String userAgent = OwnCloudClientManagerFactory.getUserAgent();
|
||||||
getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent);
|
getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent);
|
||||||
getParams().setParameter(
|
getParams().setParameter(
|
||||||
PARAM_PROTOCOL_VERSION,
|
PARAM_PROTOCOL_VERSION,
|
||||||
HttpVersion.HTTP_1_1);
|
HttpVersion.HTTP_1_1
|
||||||
|
);
|
||||||
|
|
||||||
getParams().setCookiePolicy(
|
getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
|
||||||
CookiePolicy.IGNORE_COOKIES);
|
|
||||||
getParams().setParameter(
|
getParams().setParameter(
|
||||||
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();
|
applyProxySettings();
|
||||||
|
|
||||||
@ -105,48 +107,47 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
|
|
||||||
|
|
||||||
private void applyProxySettings() {
|
private void applyProxySettings() {
|
||||||
String proxyHost = System.getProperty("http.proxyHost");
|
String proxyHost = System.getProperty("http.proxyHost");
|
||||||
String proxyPortSt = System.getProperty("http.proxyPort");
|
String proxyPortSt = System.getProperty("http.proxyPort");
|
||||||
int proxyPort = 0;
|
int proxyPort = 0;
|
||||||
try {
|
try {
|
||||||
if (proxyPortSt != null && proxyPortSt.length() > 0) {
|
if (proxyPortSt != null && proxyPortSt.length() > 0) {
|
||||||
proxyPort = Integer.parseInt(proxyPortSt);
|
proxyPort = Integer.parseInt(proxyPortSt);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// nothing to do here
|
Log_OC.w(TAG, "Proxy port could not be read, keeping default value " + proxyPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proxyHost != null && proxyHost.length() > 0) {
|
if (proxyHost != null && proxyHost.length() > 0) {
|
||||||
HostConfiguration hostCfg = getHostConfiguration();
|
HostConfiguration hostCfg = getHostConfiguration();
|
||||||
hostCfg.setProxy(proxyHost, proxyPort);
|
hostCfg.setProxy(proxyHost, proxyPort);
|
||||||
Log_OC.d(TAG, "Proxy settings: " + 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;
|
||||||
mCredentials.applyTo(this);
|
mCredentials.applyTo(this);
|
||||||
} else {
|
} else {
|
||||||
clearCredentials();
|
clearCredentials();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearCredentials() {
|
public void clearCredentials() {
|
||||||
if (!(mCredentials instanceof OwnCloudAnonymousCredentials)) {
|
if (!(mCredentials instanceof OwnCloudAnonymousCredentials)) {
|
||||||
mCredentials = OwnCloudCredentialsFactory.getAnonymousCredentials();
|
mCredentials = OwnCloudCredentialsFactory.getAnonymousCredentials();
|
||||||
}
|
}
|
||||||
mCredentials.applyTo(this);
|
mCredentials.applyTo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a file exists in the OC server
|
* Check if a file exists in the OC server
|
||||||
*
|
*
|
||||||
* @deprecated Use ExistenceCheckOperation instead
|
* @return 'true' if the file exists; 'false' it doesn't exist
|
||||||
*
|
* @throws Exception When the existence could not be determined
|
||||||
* @return 'true' if the file exists; 'false' it doesn't exist
|
* @deprecated Use ExistenceCheckOperation instead
|
||||||
* @throws Exception When the existence could not be determined
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean existsFile(String path) throws IOException, HttpException {
|
public boolean existsFile(String path) throws IOException, HttpException {
|
||||||
@ -154,7 +155,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
try {
|
try {
|
||||||
int status = executeMethod(head);
|
int status = executeMethod(head);
|
||||||
Log_OC.d(TAG, "HEAD to " + path + " finished with HTTP status " + status +
|
Log_OC.d(TAG, "HEAD to " + path + " finished with HTTP status " + status +
|
||||||
((status != HttpStatus.SC_OK)?"(FAIL)":""));
|
((status != HttpStatus.SC_OK) ? "(FAIL)" : ""));
|
||||||
exhaustResponse(head.getResponseBodyAsStream());
|
exhaustResponse(head.getResponseBodyAsStream());
|
||||||
return (status == HttpStatus.SC_OK);
|
return (status == HttpStatus.SC_OK);
|
||||||
|
|
||||||
@ -173,9 +174,9 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
* The timeouts are both in milliseconds; 0 means 'infinite';
|
* The timeouts are both in milliseconds; 0 means 'infinite';
|
||||||
* < 0 means 'do not change the default'
|
* < 0 means 'do not change the default'
|
||||||
*
|
*
|
||||||
* @param method HTTP method request.
|
* @param method HTTP method request.
|
||||||
* @param readTimeout Timeout to set for data reception
|
* @param readTimeout Timeout to set for data reception
|
||||||
* @param connectionTimeout Timeout to set for connection establishment
|
* @param connectionTimeout Timeout to set for connection establishment
|
||||||
*/
|
*/
|
||||||
public int executeMethod(HttpMethodBase method, int readTimeout, int connectionTimeout) throws IOException {
|
public int executeMethod(HttpMethodBase method, int readTimeout, int connectionTimeout) throws IOException {
|
||||||
|
|
||||||
@ -202,59 +203,82 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
*
|
*
|
||||||
* Executes the method through the inherited HttpClient.executedMethod(method).
|
* Executes the method through the inherited HttpClient.executedMethod(method).
|
||||||
*
|
*
|
||||||
* @param method HTTP method request.
|
* @param method HTTP method request.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int executeMethod(HttpMethod method) throws IOException {
|
public int executeMethod(HttpMethod method) throws IOException {
|
||||||
try {
|
// Update User Agent
|
||||||
// Update User Agent
|
HttpParams params = method.getParams();
|
||||||
HttpParams params = method.getParams();
|
String userAgent = OwnCloudClientManagerFactory.getUserAgent();
|
||||||
String userAgent = OwnCloudClientManagerFactory.getUserAgent();
|
params.setParameter(HttpMethodParams.USER_AGENT, userAgent);
|
||||||
params.setParameter(HttpMethodParams.USER_AGENT, userAgent);
|
|
||||||
|
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber, "REQUEST " +
|
preventCrashDueToInvalidPort(method);
|
||||||
method.getName() + " " + method.getPath());
|
|
||||||
|
|
||||||
// logCookiesAtRequest(method.getRequestHeaders(), "before");
|
Log_OC.d(TAG + " #" + mInstanceNumber, "REQUEST " +
|
||||||
// logCookiesAtState("before");
|
method.getName() + " " + method.getPath());
|
||||||
method.setFollowRedirects(false);
|
|
||||||
|
|
||||||
int status = super.executeMethod(method);
|
//logCookiesAtRequest(method.getRequestHeaders(), "before");
|
||||||
|
//logCookiesAtState("before");
|
||||||
|
method.setFollowRedirects(false);
|
||||||
|
|
||||||
if (mFollowRedirects) {
|
int status = super.executeMethod(method);
|
||||||
status = followRedirection(method).getLastStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
// logCookiesAtRequest(method.getRequestHeaders(), "after");
|
if (mFollowRedirects) {
|
||||||
// logCookiesAtState("after");
|
status = followRedirection(method).getLastStatus();
|
||||||
// logSetCookiesAtResponse(method.getResponseHeaders());
|
}
|
||||||
|
|
||||||
return status;
|
//logCookiesAtRequest(method.getRequestHeaders(), "after");
|
||||||
|
//logCookiesAtState("after");
|
||||||
|
//logSetCookiesAtResponse(method.getResponseHeaders());
|
||||||
|
|
||||||
} catch (IOException e) {
|
return status;
|
||||||
//Log_OC.d(TAG + " #" + mInstanceNumber, "Exception occurred", e);
|
}
|
||||||
throw e;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fix for https://github.com/owncloud/android/issues/1847#issuecomment-267558274
|
||||||
|
*
|
||||||
|
* The problem: default SocketFactory in HTTPClient 3.x for HTTP connections creates a separate thread
|
||||||
|
* to create the socket. When a port out of TCP bounds is passed, an exception is thrown in that
|
||||||
|
* separate thread, and our original thread is not able to catch it. This is not happenning with HTTPS
|
||||||
|
* connections because we had to define our own socket factory,
|
||||||
|
* {@link com.owncloud.android.lib.common.network.AdvancedSslSocketFactory}, and it does not mess with
|
||||||
|
* threads.
|
||||||
|
*
|
||||||
|
* The solution: validate the input (the port number) ourselves before let the work to HTTPClient 3.x.
|
||||||
|
*
|
||||||
|
* @param method HTTP method to run.
|
||||||
|
* @throws IllegalArgumentException If 'method' targets an invalid port in an HTTP URI.
|
||||||
|
* @throws URIException If the URI to the target server cannot be built.
|
||||||
|
*/
|
||||||
|
private void preventCrashDueToInvalidPort(HttpMethod method) throws URIException {
|
||||||
|
int port = method.getURI().getPort();
|
||||||
|
String scheme = method.getURI().getScheme().toLowerCase();
|
||||||
|
if ("http".equals(scheme) && port > 0xFFFF) {
|
||||||
|
// < 0 is not tested because -1 is used when no port number is specified in the URL;
|
||||||
|
// no problem, the network library will convert that in the default HTTP port
|
||||||
|
throw new IllegalArgumentException("Invalid port number " + port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RedirectionPath followRedirection(HttpMethod method) throws IOException {
|
public RedirectionPath followRedirection(HttpMethod method) throws IOException {
|
||||||
int redirectionsCount = 0;
|
int redirectionsCount = 0;
|
||||||
int status = method.getStatusCode();
|
int status = method.getStatusCode();
|
||||||
RedirectionPath result = new RedirectionPath(status, MAX_REDIRECTIONS_COUNT);
|
RedirectionPath result = new RedirectionPath(status, MAX_REDIRECTIONS_COUNT);
|
||||||
while (redirectionsCount < MAX_REDIRECTIONS_COUNT &&
|
while (redirectionsCount < MAX_REDIRECTIONS_COUNT &&
|
||||||
( status == HttpStatus.SC_MOVED_PERMANENTLY ||
|
(status == HttpStatus.SC_MOVED_PERMANENTLY ||
|
||||||
status == HttpStatus.SC_MOVED_TEMPORARILY ||
|
status == HttpStatus.SC_MOVED_TEMPORARILY ||
|
||||||
status == HttpStatus.SC_TEMPORARY_REDIRECT)
|
status == HttpStatus.SC_TEMPORARY_REDIRECT)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
Header location = method.getResponseHeader("Location");
|
Header location = method.getResponseHeader("Location");
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
location = method.getResponseHeader("location");
|
location = method.getResponseHeader("location");
|
||||||
}
|
}
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber,
|
Log_OC.d(TAG + " #" + mInstanceNumber,
|
||||||
"Location to redirect: " + location.getValue());
|
"Location to redirect: " + location.getValue());
|
||||||
|
|
||||||
String locationStr = location.getValue();
|
String locationStr = location.getValue();
|
||||||
result.addLocation(locationStr);
|
result.addLocation(locationStr);
|
||||||
@ -267,21 +291,21 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
method.setURI(new URI(locationStr, true));
|
method.setURI(new URI(locationStr, true));
|
||||||
Header destination = method.getRequestHeader("Destination");
|
Header destination = method.getRequestHeader("Destination");
|
||||||
if (destination == null) {
|
if (destination == null) {
|
||||||
destination = method.getRequestHeader("destination");
|
destination = method.getRequestHeader("destination");
|
||||||
}
|
}
|
||||||
if (destination != null) {
|
if (destination != null) {
|
||||||
int suffixIndex = locationStr.lastIndexOf(
|
int suffixIndex = locationStr.lastIndexOf(
|
||||||
(mCredentials instanceof OwnCloudBearerCredentials) ?
|
(mCredentials instanceof OwnCloudBearerCredentials) ?
|
||||||
AccountUtils.ODAV_PATH :
|
AccountUtils.ODAV_PATH :
|
||||||
AccountUtils.WEBDAV_PATH_4_0
|
AccountUtils.WEBDAV_PATH_4_0
|
||||||
);
|
);
|
||||||
String redirectionBase = locationStr.substring(0, suffixIndex);
|
String redirectionBase = locationStr.substring(0, suffixIndex);
|
||||||
|
|
||||||
String destinationStr = destination.getValue();
|
String destinationStr = destination.getValue();
|
||||||
String destinationPath = destinationStr.substring(mBaseUri.toString().length());
|
String destinationPath = destinationStr.substring(mBaseUri.toString().length());
|
||||||
String redirectedDestination = redirectionBase + destinationPath;
|
String redirectedDestination = redirectionBase + destinationPath;
|
||||||
|
|
||||||
destination.setValue(redirectedDestination);
|
destination.setValue(redirectedDestination);
|
||||||
method.setRequestHeader(destination);
|
method.setRequestHeader(destination);
|
||||||
}
|
}
|
||||||
status = super.executeMethod(method);
|
status = super.executeMethod(method);
|
||||||
@ -289,27 +313,27 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
redirectionsCount++;
|
redirectionsCount++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber, "No location to redirect!");
|
Log_OC.d(TAG + " #" + mInstanceNumber, "No location to redirect!");
|
||||||
status = HttpStatus.SC_NOT_FOUND;
|
status = HttpStatus.SC_NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exhausts a not interesting HTTP response. Encouraged by HttpClient documentation.
|
* Exhausts a not interesting HTTP response. Encouraged by HttpClient documentation.
|
||||||
*
|
*
|
||||||
* @param responseBodyAsStream InputStream with the HTTP response to exhaust.
|
* @param responseBodyAsStream InputStream with the HTTP response to exhaust.
|
||||||
*/
|
*/
|
||||||
public void exhaustResponse(InputStream responseBodyAsStream) {
|
public void exhaustResponse(InputStream responseBodyAsStream) {
|
||||||
if (responseBodyAsStream != null) {
|
if (responseBodyAsStream != null) {
|
||||||
try {
|
try {
|
||||||
while (responseBodyAsStream.read(sExhaustBuffer) >= 0);
|
while (responseBodyAsStream.read(sExhaustBuffer) >= 0) ;
|
||||||
responseBodyAsStream.close();
|
responseBodyAsStream.close();
|
||||||
|
|
||||||
} catch (IOException io) {
|
} catch (IOException io) {
|
||||||
Log_OC.e(TAG, "Unexpected exception while exhausting not interesting HTTP response;" +
|
Log_OC.e(TAG, "Unexpected exception while exhausting not interesting HTTP response;" +
|
||||||
" will be IGNORED", io);
|
" will be IGNORED", io);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -319,20 +343,20 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
* performed by this client.
|
* performed by this client.
|
||||||
*/
|
*/
|
||||||
public void setDefaultTimeouts(int defaultDataTimeout, int defaultConnectionTimeout) {
|
public void setDefaultTimeouts(int defaultDataTimeout, int defaultConnectionTimeout) {
|
||||||
if (defaultDataTimeout >= 0) {
|
if (defaultDataTimeout >= 0) {
|
||||||
getParams().setSoTimeout(defaultDataTimeout);
|
getParams().setSoTimeout(defaultDataTimeout);
|
||||||
}
|
}
|
||||||
if (defaultConnectionTimeout >= 0) {
|
if (defaultConnectionTimeout >= 0) {
|
||||||
getHttpConnectionManager().getParams().setConnectionTimeout(defaultConnectionTimeout);
|
getHttpConnectionManager().getParams().setConnectionTimeout(defaultConnectionTimeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uri getWebdavUri() {
|
public Uri getWebdavUri() {
|
||||||
if (mCredentials instanceof OwnCloudBearerCredentials) {
|
if (mCredentials instanceof OwnCloudBearerCredentials) {
|
||||||
return Uri.parse(mBaseUri + AccountUtils.ODAV_PATH);
|
return Uri.parse(mBaseUri + AccountUtils.ODAV_PATH);
|
||||||
} else {
|
} else {
|
||||||
return Uri.parse(mBaseUri + AccountUtils.WEBDAV_PATH_4_0);
|
return Uri.parse(mBaseUri + AccountUtils.WEBDAV_PATH_4_0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -344,7 +368,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
*/
|
*/
|
||||||
public void setBaseUri(Uri uri) {
|
public void setBaseUri(Uri uri) {
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
throw new IllegalArgumentException("URI cannot be NULL");
|
throw new IllegalArgumentException("URI cannot be NULL");
|
||||||
}
|
}
|
||||||
mBaseUri = uri;
|
mBaseUri = uri;
|
||||||
}
|
}
|
||||||
@ -365,90 +389,89 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
return mFollowRedirects;
|
return mFollowRedirects;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logCookiesAtRequest(Header[] headers, String when) {
|
private void logCookiesAtRequest(Header[] headers, String when) {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (int i=0; i<headers.length; i++) {
|
for (int i = 0; i < headers.length; i++) {
|
||||||
if (headers[i].getName().toLowerCase().equals("cookie")) {
|
if (headers[i].getName().toLowerCase().equals("cookie")) {
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber,
|
Log_OC.d(TAG + " #" + mInstanceNumber,
|
||||||
"Cookies at request (" + when + ") (" + counter++ + "): " +
|
"Cookies at request (" + when + ") (" + counter++ + "): " +
|
||||||
headers[i].getValue());
|
headers[i].getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (counter == 0) {
|
if (counter == 0) {
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber, "No cookie at request before");
|
Log_OC.d(TAG + " #" + mInstanceNumber, "No cookie at request before");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logCookiesAtState(String string) {
|
private void logCookiesAtState(String string) {
|
||||||
Cookie[] cookies = getState().getCookies();
|
Cookie[] cookies = getState().getCookies();
|
||||||
if (cookies.length == 0) {
|
if (cookies.length == 0) {
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber, "No cookie at STATE before");
|
Log_OC.d(TAG + " #" + mInstanceNumber, "No cookie at STATE before");
|
||||||
} else {
|
} else {
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber, "Cookies at STATE (before)");
|
Log_OC.d(TAG + " #" + mInstanceNumber, "Cookies at STATE (before)");
|
||||||
for (int i=0; i<cookies.length; i++) {
|
for (int i = 0; i < cookies.length; i++) {
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber, " (" + i + "):" +
|
Log_OC.d(TAG + " #" + mInstanceNumber, " (" + i + "):" +
|
||||||
"\n name: " + cookies[i].getName() +
|
"\n name: " + cookies[i].getName() +
|
||||||
"\n value: " + cookies[i].getValue() +
|
"\n value: " + cookies[i].getValue() +
|
||||||
"\n domain: " + cookies[i].getDomain() +
|
"\n domain: " + cookies[i].getDomain() +
|
||||||
"\n path: " + cookies[i].getPath()
|
"\n path: " + cookies[i].getPath()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logSetCookiesAtResponse(Header[] headers) {
|
private void logSetCookiesAtResponse(Header[] headers) {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (int i=0; i<headers.length; i++) {
|
for (int i = 0; i < headers.length; i++) {
|
||||||
if (headers[i].getName().toLowerCase().equals("set-cookie")) {
|
if (headers[i].getName().toLowerCase().equals("set-cookie")) {
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber,
|
Log_OC.d(TAG + " #" + mInstanceNumber,
|
||||||
"Set-Cookie (" + counter++ + "): " + headers[i].getValue());
|
"Set-Cookie (" + counter++ + "): " + headers[i].getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (counter == 0) {
|
if (counter == 0) {
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber, "No set-cookie");
|
Log_OC.d(TAG + " #" + mInstanceNumber, "No set-cookie");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCookiesString() {
|
||||||
|
Cookie[] cookies = getState().getCookies();
|
||||||
|
String cookiesString = "";
|
||||||
|
for (Cookie cookie : cookies) {
|
||||||
|
cookiesString = cookiesString + cookie.toString() + ";";
|
||||||
|
|
||||||
|
// logCookie(cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
return cookiesString;
|
||||||
|
|
||||||
public String getCookiesString() {
|
}
|
||||||
Cookie[] cookies = getState().getCookies();
|
|
||||||
String cookiesString = "";
|
|
||||||
for (Cookie cookie : cookies) {
|
|
||||||
cookiesString = cookiesString + cookie.toString() + ";";
|
|
||||||
|
|
||||||
// logCookie(cookie);
|
public int getConnectionTimeout() {
|
||||||
}
|
|
||||||
|
|
||||||
return cookiesString;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getConnectionTimeout() {
|
|
||||||
return getHttpConnectionManager().getParams().getConnectionTimeout();
|
return getHttpConnectionManager().getParams().getConnectionTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDataTimeout() {
|
public int getDataTimeout() {
|
||||||
return getParams().getSoTimeout();
|
return getParams().getSoTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logCookie(Cookie cookie) {
|
private void logCookie(Cookie cookie) {
|
||||||
Log_OC.d(TAG, "Cookie name: "+ cookie.getName() );
|
Log_OC.d(TAG, "Cookie name: " + cookie.getName());
|
||||||
Log_OC.d(TAG, " value: "+ cookie.getValue() );
|
Log_OC.d(TAG, " value: " + cookie.getValue());
|
||||||
Log_OC.d(TAG, " domain: "+ cookie.getDomain());
|
Log_OC.d(TAG, " domain: " + cookie.getDomain());
|
||||||
Log_OC.d(TAG, " path: "+ cookie.getPath() );
|
Log_OC.d(TAG, " path: " + cookie.getPath());
|
||||||
Log_OC.d(TAG, " version: "+ cookie.getVersion() );
|
Log_OC.d(TAG, " version: " + cookie.getVersion());
|
||||||
Log_OC.d(TAG, " expiryDate: " +
|
Log_OC.d(TAG, " expiryDate: " +
|
||||||
(cookie.getExpiryDate() != null ? cookie.getExpiryDate().toString() : "--"));
|
(cookie.getExpiryDate() != null ? cookie.getExpiryDate().toString() : "--"));
|
||||||
Log_OC.d(TAG, " comment: "+ cookie.getComment() );
|
Log_OC.d(TAG, " comment: " + cookie.getComment());
|
||||||
Log_OC.d(TAG, " secure: "+ cookie.getSecure() );
|
Log_OC.d(TAG, " secure: " + cookie.getSecure());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setOwnCloudVersion(OwnCloudVersion version){
|
public void setOwnCloudVersion(OwnCloudVersion version) {
|
||||||
mVersion = version;
|
mVersion = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OwnCloudVersion getOwnCloudVersion(){
|
public OwnCloudVersion getOwnCloudVersion() {
|
||||||
return mVersion;
|
return mVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user