1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

Fix crash when response body is empty and solve issue when retrieving auth methods

This commit is contained in:
davigonz 2020-04-16 14:40:50 +02:00 committed by agarcia
parent 64bfd6a7f7
commit f20d2554bf
2 changed files with 16 additions and 10 deletions

View File

@ -78,14 +78,18 @@ public abstract class DavMethod extends HttpBaseMethod {
.build();
} else if (mResponse != null) {
ResponseBody responseBody = ResponseBody.create(
mResponse.body().contentType(),
httpException.getResponseBody()
);
// The check below should be included in okhttp library, method ResponseBody.create(
// TODO check most recent versions of okhttp to see if this is already fixed and try to update if so
if (mResponse.body().contentType() != null) {
ResponseBody responseBody = ResponseBody.create(
mResponse.body().contentType(),
httpException.getResponseBody()
);
mResponse = mResponse.newBuilder()
.body(responseBody)
.build();
mResponse = mResponse.newBuilder()
.body(responseBody)
.build();
}
}
return httpException.getCode();

View File

@ -66,7 +66,7 @@ public class RemoteOperationResult<T>
private Exception mException = null;
private ResultCode mCode = ResultCode.UNKNOWN_ERROR;
private String mRedirectedLocation;
private String mAuthenticate;
private List<String> mAuthenticate = new ArrayList<>();
private String mLastPermanentLocation = null;
private T mData = null;
@ -253,7 +253,9 @@ public class RemoteOperationResult<T>
continue;
}
if ("www-authenticate".equals(header.getKey().toLowerCase())) {
mAuthenticate = header.getValue().get(0).toLowerCase();
for (String value: header.getValue()) {
mAuthenticate.add(value.toLowerCase());
}
}
}
}
@ -494,7 +496,7 @@ public class RemoteOperationResult<T>
return (mRedirectedLocation != null && !(mRedirectedLocation.toLowerCase().startsWith("https://")));
}
public String getAuthenticateHeaders() {
public List<String> getAuthenticateHeaders() {
return mAuthenticate;
}