code: @Override
      public ClientResponse doHandle(ClientRequest request) {
          if (request == null) {
              throw new IllegalArgumentException("Request should not be null");
          }
  
          URI originalURI = request.getURI();
          request.setURI(locationManager.getRedirectedURI(originalURI));
  
          ClientResponse response = getNext().handle(request);
          while (response.getClientResponseStatus() == ClientResponse.Status.MOVED_PERMANENTLY) {
              try {
                  locationManager.setRedirectedURI(response.getHeaders()
                          .getFirst("Location"));
              } catch (NullPointerException e) {
                  throw new ClientHandlerException(
                          "HTTP Redirect did not include Location header");
              } catch (URISyntaxException e) {
                  throw new ClientHandlerException(
                          "HTTP Redirect location is not a valid URI");
              }
  
              request.setURI(locationManager.getRedirectedURI(originalURI));
              response = getNext().handle(request);
          }
          return response;
      }
docs: /*
  (non-Javadoc)
  
  @see
  com.microsoft.windowsazure.services.core.IdempotentClientFilter#doHandle
  (com.sun.jersey.api.client.ClientRequest)