block prefetching links
git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@42 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7master
parent
f76b90af20
commit
b8f7cce3e0
|
@ -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
|
||||
|
|
Reference in New Issue