mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Handle 425 TOO EARLY propfind responses
This commit is contained in:
		
							parent
							
								
									376d52ac5b
								
							
						
					
					
						commit
						b083debac9
					
				| @ -184,6 +184,7 @@ public class HttpConstants { | |||||||
|     public static final int HTTP_LOCKED = 423; |     public static final int HTTP_LOCKED = 423; | ||||||
|     // 424 Failed Dependency (WebDAV - RFC 2518) |     // 424 Failed Dependency (WebDAV - RFC 2518) | ||||||
|     public static final int HTTP_FAILED_DEPENDENCY = 424; |     public static final int HTTP_FAILED_DEPENDENCY = 424; | ||||||
|  |     public static final int HTTP_TOO_EARLY = 425; | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * 5xx Client Error |      * 5xx Client Error | ||||||
|  | |||||||
| @ -120,7 +120,7 @@ public class RemoteFile implements Parcelable, Serializable { | |||||||
| 
 | 
 | ||||||
|     public RemoteFile(final Response davResource, String userId) { |     public RemoteFile(final Response davResource, String userId) { | ||||||
|         this(RemoteFileUtil.Companion.getRemotePathFromUrl(davResource.getHref(), userId)); |         this(RemoteFileUtil.Companion.getRemotePathFromUrl(davResource.getHref(), userId)); | ||||||
|         final List<Property> properties = davResource.getProperties(); |         final List<Property> properties = RemoteFileUtil.Companion.getProperties(davResource); | ||||||
| 
 | 
 | ||||||
|         for (Property property : properties) { |         for (Property property : properties) { | ||||||
|             if (property instanceof CreationDate) { |             if (property instanceof CreationDate) { | ||||||
|  | |||||||
| @ -24,7 +24,11 @@ | |||||||
| package com.owncloud.android.lib.resources.files | package com.owncloud.android.lib.resources.files | ||||||
| 
 | 
 | ||||||
| import android.net.Uri | import android.net.Uri | ||||||
|  | import at.bitfire.dav4jvm.PropStat | ||||||
|  | import at.bitfire.dav4jvm.Property | ||||||
|  | import at.bitfire.dav4jvm.Response | ||||||
| import com.owncloud.android.lib.common.OwnCloudClient | import com.owncloud.android.lib.common.OwnCloudClient | ||||||
|  | import com.owncloud.android.lib.common.http.HttpConstants | ||||||
| import okhttp3.HttpUrl | import okhttp3.HttpUrl | ||||||
| 
 | 
 | ||||||
| class RemoteFileUtil { | class RemoteFileUtil { | ||||||
| @ -45,5 +49,14 @@ class RemoteFileUtil { | |||||||
|             val pathToOc = absoluteDavPath.split(davFilesPath)[0] |             val pathToOc = absoluteDavPath.split(davFilesPath)[0] | ||||||
|             return absoluteDavPath.replace(pathToOc + davFilesPath, "") |             return absoluteDavPath.replace(pathToOc + davFilesPath, "") | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|  |         fun getProperties(response: Response): List<Property> { | ||||||
|  |             return if (response.isSuccess()) | ||||||
|  |                 response.propstat.filter { propStat -> propStat.isSuccessOrPostProcessing() }.map { it.properties }.flatten() | ||||||
|  |             else | ||||||
|  |                 emptyList() | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private fun PropStat.isSuccessOrPostProcessing() = (status.code / 100 == 2 || status.code == HttpConstants.HTTP_TOO_EARLY) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user