本文整理匯總了Java中com.owncloud.android.lib.common.network.RedirectionPath類的典型用法代碼示例。如果您正苦於以下問題:Java RedirectionPath類的具體用法?Java RedirectionPath怎麽用?Java RedirectionPath使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RedirectionPath類屬於com.owncloud.android.lib.common.network包,在下文中一共展示了RedirectionPath類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: followRedirection
import com.owncloud.android.lib.common.network.RedirectionPath; //導入依賴的package包/類
public RedirectionPath followRedirection(HttpMethod method) throws IOException {
int redirectionsCount = 0;
int status = method.getStatusCode();
RedirectionPath result = new RedirectionPath(status, MAX_REDIRECTIONS_COUNT);
while (redirectionsCount < MAX_REDIRECTIONS_COUNT &&
( status == HttpStatus.SC_MOVED_PERMANENTLY ||
status == HttpStatus.SC_MOVED_TEMPORARILY ||
status == HttpStatus.SC_TEMPORARY_REDIRECT)
) {
Header location = method.getResponseHeader("Location");
if (location == null) {
location = method.getResponseHeader("location");
}
if (location != null) {
Log_OC.d(TAG + " #" + mInstanceNumber,
"Location to redirect: " + location.getValue());
String locationStr = location.getValue();
result.addLocation(locationStr);
// Release the connection to avoid reach the max number of connections per host
// due to it will be set a different url
exhaustResponse(method.getResponseBodyAsStream());
method.releaseConnection();
method.setURI(new URI(locationStr, true));
Header destination = method.getRequestHeader("Destination");
if (destination == null) {
destination = method.getRequestHeader("destination");
}
if (destination != null) {
int suffixIndex = locationStr.lastIndexOf(
(mCredentials instanceof OwnCloudBearerCredentials) ?
AccountUtils.ODAV_PATH :
AccountUtils.WEBDAV_PATH_4_0
);
String redirectionBase = locationStr.substring(0, suffixIndex);
String destinationStr = destination.getValue();
String destinationPath = destinationStr.substring(mBaseUri.toString().length());
String redirectedDestination = redirectionBase + destinationPath;
destination.setValue(redirectedDestination);
method.setRequestHeader(destination);
}
status = super.executeMethod(method);
result.addStatus(status);
redirectionsCount++;
} else {
Log_OC.d(TAG + " #" + mInstanceNumber, "No location to redirect!");
status = HttpStatus.SC_NOT_FOUND;
}
}
return result;
}
示例2: getRedirectionPath
import com.owncloud.android.lib.common.network.RedirectionPath; //導入依賴的package包/類
/**
* Gets the sequence of redirections followed during the execution of the operation.
*
* @return Sequence of redirections followed, if any, or NULL if the operation was not executed.
*/
public RedirectionPath getRedirectionPath() {
return mRedirectionPath;
}