Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit b083deb

Browse files
abelgardepJuancaG05
authored andcommitted
Handle 425 TOO EARLY propfind responses
1 parent 376d52a commit b083deb

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ public class HttpConstants {
184184
public static final int HTTP_LOCKED = 423;
185185
// 424 Failed Dependency (WebDAV - RFC 2518)
186186
public static final int HTTP_FAILED_DEPENDENCY = 424;
187+
public static final int HTTP_TOO_EARLY = 425;
187188

188189
/**
189190
* 5xx Client Error

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public RemoteFile(String path) {
120120

121121
public RemoteFile(final Response davResource, String userId) {
122122
this(RemoteFileUtil.Companion.getRemotePathFromUrl(davResource.getHref(), userId));
123-
final List<Property> properties = davResource.getProperties();
123+
final List<Property> properties = RemoteFileUtil.Companion.getProperties(davResource);
124124

125125
for (Property property : properties) {
126126
if (property instanceof CreationDate) {

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFileUtil.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
package com.owncloud.android.lib.resources.files
2525

2626
import android.net.Uri
27+
import at.bitfire.dav4jvm.PropStat
28+
import at.bitfire.dav4jvm.Property
29+
import at.bitfire.dav4jvm.Response
2730
import com.owncloud.android.lib.common.OwnCloudClient
31+
import com.owncloud.android.lib.common.http.HttpConstants
2832
import okhttp3.HttpUrl
2933

3034
class RemoteFileUtil {
@@ -45,5 +49,14 @@ class RemoteFileUtil {
4549
val pathToOc = absoluteDavPath.split(davFilesPath)[0]
4650
return absoluteDavPath.replace(pathToOc + davFilesPath, "")
4751
}
52+
53+
fun getProperties(response: Response): List<Property> {
54+
return if (response.isSuccess())
55+
response.propstat.filter { propStat -> propStat.isSuccessOrPostProcessing() }.map { it.properties }.flatten()
56+
else
57+
emptyList()
58+
}
59+
60+
private fun PropStat.isSuccessOrPostProcessing() = (status.code / 100 == 2 || status.code == HttpConstants.HTTP_TOO_EARLY)
4861
}
4962
}

0 commit comments

Comments
 (0)