From b8f7cce3e0c3cd307a87d5748b96d7b3496be80f Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 17 Nov 2007 22:34:29 +0000 Subject: [PATCH] block prefetching links git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@42 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7 --- app/controllers/application.rb | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 28e57d1..7705866 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -1,5 +1,6 @@ class ApplicationController < ActionController::Base session :session_key => '_barleysodas_session_id' + append_before_filter :block_prefeching_links ## # Ensures that the request was made using an Ajax request. @@ -27,4 +28,39 @@ class ApplicationController < ActionController::Base :status => '500 Error' end end + + private + + ## + # Stops all prefetching by the Google web accelerator by returning a 403 + # forbidden error. + # + # Original Copyright: + # Copyright (c) 2005 David Heinemeier Hansson + # + # Permission is hereby granted, free of charge, to any person obtaining + # a copy of this software and associated documentation files (the + # "Software"), to deal in the Software without restriction, including + # without limitation the rights to use, copy, modify, merge, publish, + # distribute, sublicense, and/or sell copies of the Software, and to + # permit persons to whom the Software is furnished to do so, subject to + # the following conditions: + # + # The above copyright notice and this permission notice shall be + # included in all copies or substantial portions of the Software. + # + # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + # + def block_prefetching_links + if request.env["HTTP_X_MOZ"] == "prefetch" + render :nothing => true, :status => "403 Forbidden" + return false + end + end end