[PATCH] request.host should answer the forwarded host.
Reported by Austin Taylor | October 5th, 2009 @ 05:57 PM | in 1.1
It seems like this should be Rack's responsibility, but I see that Rails is handling it in ActionController::Request like this:
# Returns the \host for this request, such as "example.com".
def raw_host_with_port
if forwarded = env["HTTP_X_FORWARDED_HOST"]
forwarded.split(/,\s?/).last
else
env['HTTP_HOST'] || "#{env['SERVER_NAME'] || env['SERVER_ADDR']}:#{env['SERVER_PORT']}"
end
end
# Returns the host for this request, such as example.com.
def host
raw_host_with_port.sub(/:\d+$/, '')
end
This is important when you are using a proxy server (mongrel, thin) and want your application to display an absolute url for some reason. This isn't working in Sinatra right now. I reported the behavior on the Sinatra Lighthouse and they directed me here. Sinatra ticket
Comments and changes to this ticket
-
Austin Taylor October 20th, 2009 @ 09:46 PM
- Assigned user set to Ryan Tomayko
- Title changed from request.host should answer the forwarded host. to [PATCH] request.host should answer the forwarded host.
Created a patch that modifies Request, and the Request spec. The implementation is based on the code in the Rails project.
-
josh December 11th, 2009 @ 03:16 AM
- Assigned user changed from Ryan Tomayko to josh
- State changed from new to open
- Milestone set to 1.1
-
josh December 21st, 2009 @ 02:52 AM
- State changed from open to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป