def _ajax_redirect(url)
      return false if url.nil? || !Ajax.is_enabled?
      special_redirect = false
      original_url = url

      # If we have the full referrer in Ajax-Info, use that because it
      # includes the fragment.
      if url == request.headers["Referer"] && !Ajax.get_header(request, :referer).blank?
        url = Ajax.get_header(request, :referer)
        Ajax.logger.debug("[ajax] using referer #{url} from Ajax-Info")
      end

      if !Ajax.exclude_path?(url)
        # Never redirect to the Ajax framework path, redirect to /
        if url =~ %r[#{Ajax.framework_path}]
          url = url.sub(%r[#{Ajax.framework_path}], '/')

          # Special case:
          #
          # Changing protocol forces a redirect from root to root.
          # The full request URL (including the hashed part) is
          # in the browser.  So return JS to do the redirect and
          # have it include the hashed part in the redirect URL.
          if !request.xhr? && URI.parse(url).scheme != URI.parse(request.url).scheme
            special_redirect = true
          end
        end

        if !Ajax.is_hashed_url?(url) and !Ajax.is_robot?(request.user_agent)
          url = Ajax.hashed_url_from_traditional(url)
        end
      end
      Ajax.logger.info("[ajax] rewrote redirect from #{original_url} to #{url}") unless original_url == url

      # Don't store session[:redirected_to] if doing a special redirect otherwise
      # when the next request for root comes in it will think we really want
      # to display the home page.
      #
      # Use the hashed part of the URL in the browser but replace the protocol
      # and host.
      #
      # +url+ is in it's hashed form so it ends with /# or /#!
      if special_redirect
        session[:redirected_to] = nil
        Ajax.logger.info("[ajax] returning special redirect JS")
        render :layout => false, :text => <<-END
<script type="text/javascript">
var url = #{url.to_json};
var hash = document.location.hash;
// Remove leading # from fragment
if (hash.charAt(0) == '#') {
  hash = hash.substr(1);
}
// Remove leading ! from fragment
if (hash.charAt(0) == '!') {
  hash = hash.substr(1);
}
// Remove leading / from the fragment if the URL already ends in a /
// to prevent double-slashes.
if (hash.charAt(0) == '/' && url.charAt(url.length - 1) == '/') {
  hash = hash.substr(1);
}
document.location.href = url + hash;
</script>
END
      else
        session[:redirected_to] = url
        if request.xhr? && Ajax.is_hashed_url?(url)
          Ajax.logger.info("[ajax] detecting we are xhr. soft redirect")
          redirect_path = Ajax.normalized_url_fragment(url)
          Ajax.logger.info("[ajax] redirect path is #{redirect_path}")
          Ajax.set_header(response, :soft_redirect, redirect_path)
          render :layout => false, :text => <<-END
<script type="text/javascript">
window.location.href = #{url.to_json};
</script>
END
        else
          return false
        end
      end
      true
    end
def _ajax_redirect(url)
      return false if url.nil? || !Ajax.is_enabled?
      special_redirect = false
      original_url = url

      # If we have the full referrer in Ajax-Info, use that because it
      # includes the fragment.
      if url == request.headers["Referer"] && !Ajax.get_header(request, :referer).blank?
        url = Ajax.get_header(request, :referer)
        Ajax.logger.debug("[ajax] using referer #{url} from Ajax-Info")
      end

      if !Ajax.exclude_path?(url)
        # Never redirect to the Ajax framework path, redirect to /
        if url =~ %r[#{Ajax.framework_path}]
          url = url.sub(%r[#{Ajax.framework_path}], '/')

          # Special case:
          #
          # Changing protocol forces a redirect from root to root.
          # The full request URL (including the hashed part) is
          # in the browser.  So return JS to do the redirect and
          # have it include the hashed part in the redirect URL.
          if !request.xhr? && URI.parse(url).scheme != URI.parse(request.url).scheme
            special_redirect = true
          end
        end

        if !Ajax.is_hashed_url?(url) and !Ajax.is_robot?(request.user_agent)
          url = Ajax.hashed_url_from_traditional(url)
        end
      end
      Ajax.logger.info("[ajax] rewrote redirect from #{original_url} to #{url}") unless original_url == url

      # Don't store session[:redirected_to] if doing a special redirect otherwise
      # when the next request for root comes in it will think we really want
      # to display the home page.
      #
      # Use the hashed part of the URL in the browser but replace the protocol
      # and host.
      #
      # +url+ is in it's hashed form so it ends with /# or /#!
      if special_redirect
        session[:redirected_to] = nil
        Ajax.logger.info("[ajax] returning special redirect JS")
        render :layout => false, :text => <<-END
<script type="text/javascript">
var url = #{url.to_json};
var hash = document.location.hash;
// Remove leading # from fragment
if (hash.charAt(0) == '#') {
  hash = hash.substr(1);
}
// Remove leading ! from fragment
if (hash.charAt(0) == '!') {
  hash = hash.substr(1);
}
// Remove leading / from the fragment if the URL already ends in a /
// to prevent double-slashes.
if (hash.charAt(0) == '/' && url.charAt(url.length - 1) == '/') {
  hash = hash.substr(1);
}
document.location.href = url + hash;
</script>
END
      else
        session[:redirected_to] = url
        if request.xhr? && Ajax.is_hashed_url?(url)
          Ajax.logger.info("[ajax] detecting we are xhr. soft redirect")
          redirect_path = Ajax.normalized_url_fragment(url)
          Ajax.logger.info("[ajax] redirect path is #{redirect_path}")
          Ajax.set_header(response, :soft_redirect, redirect_path)
          render :layout => false, :text => <<-END
<script type="text/javascript">
window.location.href = #{url.to_json};
</script>
END
        else
          return false
        end
      end
      true
    end
Perform special processing on the response if we need to.
 Return true if an Ajax "redirect" was performed, and false
 otherwise.