當前位置: 首頁>>代碼示例>>Java>>正文


Java RedirectionPath類代碼示例

本文整理匯總了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;
}
 
開發者ID:PicFrame,項目名稱:picframe,代碼行數:58,代碼來源:OwnCloudClient.java

示例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;
}
 
開發者ID:PicFrame,項目名稱:picframe,代碼行數:9,代碼來源:ExistenceCheckRemoteOperation.java


注:本文中的com.owncloud.android.lib.common.network.RedirectionPath類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。