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

Commit 14baadd

Browse files
committed
Webfinger calls won't follow redirections. Only working with 2XX
1 parent fa65c1a commit 14baadd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/webfinger/GetInstancesViaWebFingerOperation.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,17 @@ class GetInstancesViaWebFingerOperation(
7575
val response = parseResponse(rawResponse)
7676
Timber.d("Successful WebFinger request: $response")
7777
val operationResult = RemoteOperationResult<List<String>>(RemoteOperationResult.ResultCode.OK)
78-
operationResult.data = response.links.map { it.href }
78+
operationResult.data = response.links?.map { it.href } ?: listOf()
7979
return operationResult
8080
}
8181

8282
override fun run(client: OwnCloudClient): RemoteOperationResult<List<String>> {
8383
val requestUri = buildRequestUri()
8484
val getMethod = GetMethod(URL(requestUri.toString()))
85+
86+
// First iteration won't follow redirections.
87+
getMethod.followRedirects = false
88+
8589
return try {
8690
val status = client.executeHttpMethod(getMethod)
8791
val response = getMethod.getResponseBodyAsString()!!

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/webfinger/responses/WebFingerResponse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import com.squareup.moshi.JsonClass
2929
@JsonClass(generateAdapter = true)
3030
data class WebFingerResponse(
3131
val subject: String,
32-
val links: List<LinkItem>
32+
val links: List<LinkItem>?
3333
)
3434

3535
@JsonClass(generateAdapter = true)

0 commit comments

Comments
 (0)