+ int status = super.executeMethod(method);
+ int redirectionsCount = 0;
+ while (mFollowRedirects &&
+ redirectionsCount < MAX_REDIRECTIONS_COUNT &&
+ customRedirectionNeeded &&
+ ( status == HttpStatus.SC_MOVED_PERMANENTLY ||
+ status == HttpStatus.SC_MOVED_TEMPORARILY ||
+ status == HttpStatus.SC_TEMPORARY_REDIRECT)
+ ) {
+ Header location = method.getResponseHeader("Location");
+ if (location != null) {
+ Log_OC.d(TAG, "Location to redirect: " + location.getValue());
+ method.setURI(new URI(location.getValue(), true));
+ status = super.executeMethod(method);
+ redirectionsCount++;
+
+ } else {
+ Log_OC.d(TAG, "No location to redirect!");
+ status = HttpStatus.SC_NOT_FOUND;
+ }
+ }
+
+ return status;