def redirected(exception)
      redirected = false
      location = exception.response.headers[:location]
      if location.nil? || location.empty?
        ErrorTracker.log(self, "Redirect exception does contain a redirect location")
      else
        new_url = URI.parse(location)
        if new_url.scheme !~ /http/ || new_url.host.empty?
          ErrorTracker.log(self, "Failed redirect because location is invalid: #{location.inspect}")
        else
          # Apply scheme and host from new URL to existing URL, but not path
          new_url.path = URI.parse(@api_url).path
          @api_url = new_url.to_s
          Log.info("Updating RightApi URL to #{@api_url.inspect} due to redirect to #{location.inspect}")
          @stats["state"].update("redirect")
          create_http_client
          redirected = true
        end
      end
      redirected
    end
def redirected(exception)
      redirected = false
      location = exception.response.headers[:location]
      if location.nil? || location.empty?
        ErrorTracker.log(self, "Redirect exception does contain a redirect location")
      else
        new_url = URI.parse(location)
        if new_url.scheme !~ /http/ || new_url.host.empty?
          ErrorTracker.log(self, "Failed redirect because location is invalid: #{location.inspect}")
        else
          # Apply scheme and host from new URL to existing URL, but not path
          new_url.path = URI.parse(@api_url).path
          @api_url = new_url.to_s
          Log.info("Updating RightApi URL to #{@api_url.inspect} due to redirect to #{location.inspect}")
          @stats["state"].update("redirect")
          create_http_client
          redirected = true
        end
      end
      redirected
    end
Handle redirect by adjusting URLs to requested location and recreating HTTP client

 @param [RightScale::BalancedHttpClient::Redirect] exception containing redirect location,
   which is required to be a full URL

 @return [Boolean] whether successfully redirected