mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 16:36:13 +00:00
Redirect 'destination' header in custom redirections
This commit is contained in:
parent
2ef5d3baf3
commit
df84917376
@ -225,6 +225,26 @@ public class OwnCloudClient extends HttpClient {
|
||||
Log.d(TAG + " #" + mInstanceNumber,
|
||||
"Location to redirect: " + location.getValue());
|
||||
method.setURI(new URI(location.getValue(), true));
|
||||
Header destination = method.getRequestHeader("Destination");
|
||||
if (destination == null) {
|
||||
destination = method.getRequestHeader("destination");
|
||||
}
|
||||
if (destination != null) {
|
||||
String locationStr = location.getValue();
|
||||
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);
|
||||
redirectionsCount++;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user