Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10549 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH] asset_host proc should take a 2nd (optional) request parameter to deal with HTTPS requests

Reported by: tomtaylor Assigned to: core
Priority: low Milestone: 2.x
Component: ActionPack Version: edge
Severity: normal Keywords:
Cc: chuyeow

Description

Using asset_host with an HTTPS connections either requires forcing the asset_host to use HTTP only (config.action_controller. asset_host = "http://assets%d.example.com"), resulting in a mixed media warning, or to not specify a protocol (config.action_controller. asset_host = "assets%d.example.com") which requires an SSL certificate for each of the asset hosts.

It would be great if there was an option to disable the asset hosting for HTTPS connections only.

I'll try and work on a patch for this in the next couple of weeks, but I thought I'd file this in here in case anyone has already done on this.

Attachments

asset_hosts_proc_with_2nd_request_parameter.diff (7.8 kB) - added by chuyeow on 01/06/08 07:24:22.

Change History

12/18/07 16:53:14 changed by chuyeow

  • cc set to chuyeow.

Not sure if the change described in #10521 is sufficient for your needs (I think not). But just thought I'd mention it anyway as it may help you with your patch to be aware of this other way of setting an asset_host.

01/05/08 22:32:31 changed by peter_b

I agree that a solution for this is needed. My solution was to also pass the protocol to the asset_host proc:

def compute_asset_host(source)

if host = ActionController::Base.asset_host

if host.is_a?(Proc)

- host.call(source) + host.call(source, @controller.request.protocol)

else

host % (source.hash % 4)

end

end

end

01/06/08 06:07:32 changed by bitsweat

How about passing the whole request as a second arg to the asset_host block.

01/06/08 07:04:17 changed by chuyeow

  • summary changed from Option to disable asset_host for HTTPS connections to [PATCH] asset_host proc should take a 2nd (optional) request parameter to deal with HTTPS requests.

Added a patch for that allows a 2nd (optional) request parameter in the proc.

There're some doc fixes in there as well as I was checking some docs while making this patch and a rdoc fix for a nodoc annotation that wasn't working properly (the SessionFixationAttempt class still appears in the rdocs when it isn't documented).

01/06/08 07:24:22 changed by chuyeow

  • attachment asset_hosts_proc_with_2nd_request_parameter.diff added.

01/06/08 07:24:55 changed by chuyeow

Replacing test and doc with a cleaner example proc.

01/06/08 20:53:28 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [8578]) The asset_host block takes the controller request as an optional second argument. Example: use a single asset host for SSL requests. Closes #10549.