aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-02-25 20:16:58 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-02-25 20:16:58 +0000
commit9b46f693819008f16cfe319e3dbe7f9d67cd2083 (patch)
tree19b3e00a339951b8a6b9eab9033b2bc4a50577f8
parent784298008bf25c901564929d319eb631eb1a5639 (diff)
downloadrails-9b46f693819008f16cfe319e3dbe7f9d67cd2083.tar.gz
rails-9b46f693819008f16cfe319e3dbe7f9d67cd2083.tar.bz2
rails-9b46f693819008f16cfe319e3dbe7f9d67cd2083.zip
Allow send_file/send_data to use a registered mime type as the :type parameter #7620 [jonathan]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6233 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/streaming.rb2
-rw-r--r--actionpack/test/controller/send_file_test.rb6
3 files changed, 7 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 1767443f12..59a3ab413e 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Allow send_file/send_data to use a registered mime type as the :type parameter #7620 [jonathan]
+
* Allow routing requirements on map.resource(s) #7633 [quixoten]. Example:
map.resources :network_interfaces, :requirements => { :id => /^\d+\.\d+\.\d+\.\d+$/ }
diff --git a/actionpack/lib/action_controller/streaming.rb b/actionpack/lib/action_controller/streaming.rb
index f82d7cf397..2e934067ac 100644
--- a/actionpack/lib/action_controller/streaming.rb
+++ b/actionpack/lib/action_controller/streaming.rb
@@ -124,7 +124,7 @@ module ActionController #:nodoc:
headers.update(
'Content-Length' => options[:length],
- 'Content-Type' => options[:type].strip, # fixes a problem with extra '\r' with some browsers
+ 'Content-Type' => options[:type].to_s.strip, # fixes a problem with extra '\r' with some browsers
'Content-Disposition' => disposition,
'Content-Transfer-Encoding' => 'binary'
)
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb
index 86f83d4539..2d876c1bb0 100644
--- a/actionpack/test/controller/send_file_test.rb
+++ b/actionpack/test/controller/send_file_test.rb
@@ -26,6 +26,8 @@ SendFileController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
class SendFileTest < Test::Unit::TestCase
include TestFileUtils
+ Mime::Type.register "image/png", :png unless defined? Mime::PNG
+
def setup
@controller = SendFileController.new
@request = ActionController::TestRequest.new
@@ -83,7 +85,7 @@ class SendFileTest < Test::Unit::TestCase
def test_send_file_headers!
options = {
:length => 1,
- :type => 'type',
+ :type => Mime::PNG,
:disposition => 'disposition',
:filename => 'filename'
}
@@ -98,7 +100,7 @@ class SendFileTest < Test::Unit::TestCase
h = @controller.headers
assert_equal 1, h['Content-Length']
- assert_equal 'type', h['Content-Type']
+ assert_equal 'image/png', h['Content-Type']
assert_equal 'disposition; filename="filename"', h['Content-Disposition']
assert_equal 'binary', h['Content-Transfer-Encoding']