Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial import

  • Loading branch information...
commit ac538590984a66c73dd80dec169236798f7181d7 0 parents
@shuber authored
1  .gitignore
@@ -0,0 +1 @@
+.DS_Store
2  CHANGELOG
@@ -0,0 +1,2 @@
+2008-09-29 - Sean Huber (shuber@huberry.com)
+ * Initial import
20 MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2008 Sean Huber (shuber@huberry.com)
+
+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.
0  README.markdown
No changes.
2  init.rb
@@ -0,0 +1,2 @@
+require 'proxy'
+$:.unshift File.join(File.dirname(__FILE__), 'lib')
39 lib/huberry/action_controller/base.rb
@@ -0,0 +1,39 @@
+module Huberry
+ module ActionController
+ module Base
+ def self.included(base)
+ base.class_eval do
+ cattr_accessor :relative_url_root
+ alias_method_chain :redirect_to, :forwarded_host
+ around_filter :set_relative_url_root
+ end
+ end
+
+ def redirect_to_with_forwarded_host(options = {}, response_status = {})
+ unless request.env['HTTP_X_FORWARDED_HOST'].blank?
+ host = request.env['HTTP_X_FORWARDED_HOST'].split(', ').first
+ if options.is_a? Hash
+ options[:host] = host
+ else
+ request.instance_variable_set('@host_with_port', host + request.port_string)
+ end
+ end
+ redirect_to_without_forwarded_host(options, response_status)
+ end
+
+ def set_relative_url_root
+ if self.class.relative_url_root.blank?
+ yield
+ else
+ @original_relative_url_root = ActionController::AbstractRequest.relative_url_root.to_s
+ ActionController::AbstractRequest.relative_url_root = self.class.relative_url_root
+ begin
+ yield
+ ensure
+ ActionController::AbstractRequest.relative_url_root = @original_relative_url_root
+ end
+ end
+ end
+ end
+ end
+end
14 lib/huberry/action_controller/dispatcher.rb
@@ -0,0 +1,14 @@
+module Huberry
+ module ActionController
+ module Dispatcher
+ def self.included(base)
+ base.send :before_dispatch, :set_session_domain
+ end
+
+ def set_session_domain
+ host = @request.env['HTTP_X_FORWARDED_HOST'].blank? ? @request.host : @request.env['HTTP_X_FORWARDED_HOST'].split(', ').first
+ ApplicationController.session_options.merge!(:session_domain => ".#{$1}") if /([^\.]+\.[^\.]+)$/.match(host)
+ end
+ end
+ end
+end
5 lib/proxy.rb
@@ -0,0 +1,5 @@
+require 'huberry/action_controller/dispatcher'
+require 'huberry/action_controller/base'
+
+::ActionController::Dispatcher.send :include, ::Huberry::ActionController::Dispatcher
+::ActionController::Base.send :include, ::Huberry::ActionController::Base
4 test/base.rb
@@ -0,0 +1,4 @@
+require File.dirname(__FILE__) + '/init'
+
+class BaseTest < Test::Unit::TestCase
+end
4 test/dispatcher_test.rb
@@ -0,0 +1,4 @@
+require File.dirname(__FILE__) + '/init'
+
+class DispatcherTest < Test::Unit::TestCase
+end
29 test/init.rb
@@ -0,0 +1,29 @@
+$:.reject! { |path| path.include? 'TextMate' }
+require 'test/unit'
+
+# Load rubygems
+#
+require 'rubygems'
+
+# Load ActionPack
+#
+gem 'actionpack'
+require 'action_pack'
+require 'action_controller'
+require 'action_controller/dispatcher'
+require 'action_controller/routing'
+require 'action_controller/assertions'
+require 'action_controller/test_process'
+
+# Routing
+#
+class ActionController::Routing::RouteSet
+ def append
+ yield Mapper.new(self)
+ install_helpers
+ end
+end
+
+# Require the main proxy.rb file
+#
+require File.join(File.dirname(File.dirname(__FILE__)), 'lib', 'proxy')

0 comments on commit ac53859

Please sign in to comment.
Something went wrong with that request. Please try again.